@Test public void joinNoPKFailed() { builder.table("j3").colInt("c1").joinTo("t3").on("c1", "c1"); Collection<AISValidationFailure> failures = builder.unvalidatedAIS().validate(validations).failures(); Assert.assertEquals(1, failures.size()); AISValidationFailure fail = failures.iterator().next(); Assert.assertEquals(ErrorCode.JOIN_PARENT_NO_PK, fail.errorCode()); }
@Override public void validate(AkibanInformationSchema ais, AISValidationOutput output) { for (Join join : ais.getJoins().values()) { if (join.getParent().getPrimaryKey() == null) { output.reportFailure(new AISValidationFailure( new JoinParentNoExplicitPK (join.getParent().getName()))); continue; } TableIndex parentPK= join.getParent().getPrimaryKey().getIndex(); if (parentPK.getKeyColumns().size() != join.getJoinColumns().size()) { output.reportFailure(new AISValidationFailure( new JoinColumnMismatchException (join.getJoinColumns().size(), join.getChild().getName(), join.getParent().getName(), parentPK.getKeyColumns().size()))); continue; } Iterator<JoinColumn> joinColumns = join.getJoinColumns().iterator(); for (IndexColumn parentPKColumn : parentPK.getKeyColumns()) { JoinColumn joinColumn = joinColumns.next(); if (parentPKColumn.getColumn() != joinColumn.getParent()) { output.reportFailure(new AISValidationFailure ( new JoinToWrongColumnsException ( join.getChild().getName(), joinColumn.getParent().getName(), parentPK.getTable().getName(), parentPKColumn.getColumn().getName()))); } } } }
JoinToParentPK implements AISValidation { @Override public void validate(AkibanInformationSchema ais, AISValidationOutput output) { for (Join join : ais.getJoins().values()) { if (join.getParent().getPrimaryKey() == null) { output.reportFailure(new AISValidationFailure( new JoinParentNoExplicitPK (join.getParent().getName()))); continue; } TableIndex parentPK= join.getParent().getPrimaryKey().getIndex(); if (parentPK.getKeyColumns().size() != join.getJoinColumns().size()) { output.reportFailure(new AISValidationFailure( new JoinColumnMismatchException (join.getJoinColumns().size(), join.getChild().getName(), join.getParent().getName(), parentPK.getKeyColumns().size()))); continue; } Iterator<JoinColumn> joinColumns = join.getJoinColumns().iterator(); for (IndexColumn parentPKColumn : parentPK.getKeyColumns()) { JoinColumn joinColumn = joinColumns.next(); if (parentPKColumn.getColumn() != joinColumn.getParent()) { output.reportFailure(new AISValidationFailure ( new JoinToWrongColumnsException ( join.getChild().getName(), joinColumn.getParent().getName(), parentPK.getTable().getName(), parentPKColumn.getColumn().getName()))); } } } } }
JoinToParentPK implements AISValidation { @Override public void validate(AkibanInformationSchema ais, AISValidationOutput output) { for (Join join : ais.getJoins().values()) { if (join.getParent().getPrimaryKey() == null) { output.reportFailure(new AISValidationFailure( new JoinParentNoExplicitPK (join.getParent().getName()))); continue; } TableIndex parentPK= join.getParent().getPrimaryKey().getIndex(); if (parentPK.getKeyColumns().size() != join.getJoinColumns().size()) { output.reportFailure(new AISValidationFailure( new JoinColumnMismatchException (join.getJoinColumns().size(), join.getChild().getName(), join.getParent().getName(), parentPK.getKeyColumns().size()))); continue; } Iterator<JoinColumn> joinColumns = join.getJoinColumns().iterator(); for (IndexColumn parentPKColumn : parentPK.getKeyColumns()) { JoinColumn joinColumn = joinColumns.next(); if (parentPKColumn.getColumn() != joinColumn.getParent()) { output.reportFailure(new AISValidationFailure ( new JoinToWrongColumnsException ( join.getChild().getName(), joinColumn.getParent().getName(), parentPK.getTable().getName(), parentPKColumn.getColumn().getName()))); } } } }  }
JoinToParentPK implements AISValidation { @Override public void validate(AkibanInformationSchema ais, AISValidationOutput output) { for (Join join : ais.getJoins().values()) { if (join.getParent().getPrimaryKey() == null) { output.reportFailure(new AISValidationFailure( new JoinParentNoExplicitPK (join.getParent().getName()))); continue; } TableIndex parentPK= join.getParent().getPrimaryKey().getIndex(); if (parentPK.getKeyColumns().size() != join.getJoinColumns().size()) { output.reportFailure(new AISValidationFailure( new JoinColumnMismatchException (join.getJoinColumns().size(), join.getChild().getName(), join.getParent().getName(), parentPK.getKeyColumns().size()))); continue; } Iterator<JoinColumn> joinColumns = join.getJoinColumns().iterator(); for (IndexColumn parentPKColumn : parentPK.getKeyColumns()) { JoinColumn joinColumn = joinColumns.next(); if (parentPKColumn.getColumn() != joinColumn.getParent()) { output.reportFailure(new AISValidationFailure ( new JoinToWrongColumnsException ( join.getChild().getName(), joinColumn.getParent().getName(), parentPK.getTable().getName(), parentPKColumn.getColumn().getName()))); } } } }  @Override void validate(AkibanInformationSchema ais, AISValidationOutput output); }
JoinToParentPK implements AISValidation { @Override public void validate(AkibanInformationSchema ais, AISValidationOutput output) { for (Join join : ais.getJoins().values()) { if (join.getParent().getPrimaryKey() == null) { output.reportFailure(new AISValidationFailure( new JoinParentNoExplicitPK (join.getParent().getName()))); continue; } TableIndex parentPK= join.getParent().getPrimaryKey().getIndex(); if (parentPK.getKeyColumns().size() != join.getJoinColumns().size()) { output.reportFailure(new AISValidationFailure( new JoinColumnMismatchException (join.getJoinColumns().size(), join.getChild().getName(), join.getParent().getName(), parentPK.getKeyColumns().size()))); continue; } Iterator<JoinColumn> joinColumns = join.getJoinColumns().iterator(); for (IndexColumn parentPKColumn : parentPK.getKeyColumns()) { JoinColumn joinColumn = joinColumns.next(); if (parentPKColumn.getColumn() != joinColumn.getParent()) { output.reportFailure(new AISValidationFailure ( new JoinToWrongColumnsException ( join.getChild().getName(), joinColumn.getParent().getName(), parentPK.getTable().getName(), parentPKColumn.getColumn().getName()))); } } } }  @Override void validate(AkibanInformationSchema ais, AISValidationOutput output);  }