Skip to content

Commit

Permalink
pr fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Pawel Czajka committed Dec 7, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 9a389e4 commit 1b80d56
Showing 1 changed file with 12 additions and 23 deletions.
35 changes: 12 additions & 23 deletions src/main/java/pl/touk/flink/ignite/dialect/IgniteDialect.java
Original file line number Diff line number Diff line change
@@ -15,6 +15,15 @@
public class IgniteDialect extends AbstractDialect {
private static final long serialVersionUID = 1L;

// copied from PostgresDialect class
private static final int MAX_TIMESTAMP_PRECISION = 6;
// copied from PostgresDialect class
private static final int MIN_TIMESTAMP_PRECISION = 1;
// copied from PostgresDialect class
private static final int MAX_DECIMAL_PRECISION = 1000;
// copied from PostgresDialect class
private static final int MIN_DECIMAL_PRECISION = 1;

@Override
public String dialectName() {
return "Ignite";
@@ -40,32 +49,11 @@ public Optional<String> defaultDriverName() {
return Optional.of("org.apache.ignite.IgniteJdbcThinDriver");
}

// WARNING code below was taken from PostgresDialect, it can turn out to be wrong

private static final int MAX_TIMESTAMP_PRECISION = 6;
private static final int MIN_TIMESTAMP_PRECISION = 1;

private static final int MAX_DECIMAL_PRECISION = 1000;
private static final int MIN_DECIMAL_PRECISION = 1;

// not supported for now, probably merge can be used https://ignite.apache.org/docs/latest/sql-reference/dml#merge
@Override
public Optional<String> getUpsertStatement(
String tableName, String[] fieldNames, String[] uniqueKeyFields) {
String uniqueColumns =
Arrays.stream(uniqueKeyFields)
.map(this::quoteIdentifier)
.collect(Collectors.joining(", "));
String updateClause =
Arrays.stream(fieldNames)
.map(f -> quoteIdentifier(f) + "=EXCLUDED." + quoteIdentifier(f))
.collect(Collectors.joining(", "));
return Optional.of(
getInsertIntoStatement(tableName, fieldNames)
+ " ON CONFLICT ("
+ uniqueColumns
+ ")"
+ " DO UPDATE SET "
+ updateClause);
return Optional.empty();
}

@Override
@@ -78,6 +66,7 @@ public Optional<Range> timestampPrecisionRange() {
return Optional.of(Range.of(MIN_TIMESTAMP_PRECISION, MAX_TIMESTAMP_PRECISION));
}

// copied from PostgresDialect class
@Override
public Set<LogicalTypeRoot> supportedTypes() {
return EnumSet.of(

0 comments on commit 1b80d56

Please sign in to comment.