Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
bobhan1 committed Oct 17, 2023
1 parent 28df39a commit 24c54d7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -379,16 +379,6 @@ public PlanFragment visitPhysicalOlapTableSink(PhysicalOlapTableSink<? extends P
boolean isPartialUpdate = olapTableSink.isPartialUpdate();
OlapTable olapTable = (OlapTable) olapTableSink.getTargetTable();

if (olapTable.hasSequenceCol() && olapTable.getSequenceMapCol() != null
&& !olapTableSink.getOutput().isEmpty() && olapTableSink.isFromNativeInsertStmt()) {
Optional<Slot> foundCol = olapTableSink.getOutput().stream()
.filter(slot -> slot.getName().equalsIgnoreCase(olapTable.getSequenceMapCol())).findAny();
if (!foundCol.isPresent() && !isPartialUpdate) {
throw new AnalysisException("Table " + olapTable.getName()
+ " has sequence column, need to specify the sequence column");
}
}

if (isPartialUpdate) {
if (!olapTable.getEnableUniqueKeyMergeOnWrite()) {
throw new AnalysisException("Partial update is only allowed in"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,21 @@ public List<Rule> buildRules() {
throw new AnalysisException("insert into cols should be corresponding to the query output");
}

try {
if (table.hasSequenceCol() && table.getSequenceMapCol() != null && !boundSink.isPartialUpdate()) {
Column seqCol = table.getFullSchema().stream()
.filter(col -> col.getName().equals(table.getSequenceMapCol()))
.findFirst().get();
if (seqCol.getDefaultValue() == null
|| !seqCol.getDefaultValue().equals(DefaultValue.CURRENT_TIMESTAMP)) {
throw new AnalysisException("Table " + table.getName()
+ " has sequence column, need to specify the sequence column");
}
}
} catch (Exception e) {
throw new AnalysisException(e.getMessage(), e.getCause());
}

Map<Column, NamedExpression> columnToChildOutput = Maps.newHashMap();
for (int i = 0; i < boundSink.getCols().size(); ++i) {
columnToChildOutput.put(boundSink.getCols().get(i), child.getOutput().get(i));
Expand Down

0 comments on commit 24c54d7

Please sign in to comment.