Skip to content

Commit

Permalink
Avro array datatype support
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Henneberger <git@danielhenneberger.com>
  • Loading branch information
henneberger committed Nov 8, 2024
1 parent 0681be4 commit 71ecfde
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 486 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public SqlDataTypeSpec getCastSpec(RelDataType type) {
castSpec = "TIMESTAMP WITH TIME ZONE";
break;
case ARRAY:
castSpec = getCastSpec(type.getComponentType()) + "[]";
castSpec = "jsonb";
break;
case BINARY:
case VARBINARY:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ protected JdbcSerializationConverter wrapIntoNullableExternalConverter(
jdbcSerializationConverter.serialize(val, index, statement);
}
};
} else if (type.getTypeRoot() == ROW) {
return (val, index, statement) -> setRow(type, val, index, statement);
} else if (type.getTypeRoot() == MAP) {
return (val, index, statement) -> setRow(type, val, index, statement);
}
return super.wrapIntoNullableExternalConverter(jdbcSerializationConverter, type);
}
Expand Down Expand Up @@ -87,30 +83,13 @@ protected JdbcSerializationConverter createExternalConverter(LogicalType type) {
return (val, index, statement) ->
statement.setTimestamp(
index, val.getTimestamp(index, tsPrecision).toTimestamp());
case ARRAY:
return (val, index, statement) -> setArray(type, val, index, statement);
case ROW:
return (val, index, statement) -> setRow(type, val, index, statement);
case MAP:
return (val, index, statement) -> setRow(type, val, index, statement);
case MULTISET:
case RAW:
default:
return super.createExternalConverter(type);
}
}

public abstract void setRow(LogicalType type, RowData val, int index,
FieldNamedPreparedStatement statement);
@SneakyThrows
public void setArray(LogicalType type, RowData val, int index, FieldNamedPreparedStatement statement) {
SqrlFieldNamedPreparedStatementImpl flinkPreparedStatement = (SqrlFieldNamedPreparedStatementImpl) statement;
for (int idx : flinkPreparedStatement.getIndexMapping()[index]) {
ArrayData arrayData = val.getArray(index);
createSqlArrayObject(type, arrayData, idx, flinkPreparedStatement.getStatement());
}
}

@SneakyThrows
private void createSqlArrayObject(LogicalType type, ArrayData data, int idx,
PreparedStatement statement) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,6 @@ public SqrlPostgresRowConverter(RowType rowType) {
super(rowType);
}

@SneakyThrows
public void setRow(LogicalType type, RowData val, int index,
FieldNamedPreparedStatement statement) {
SqrlFieldNamedPreparedStatementImpl flinkPreparedStatement = (SqrlFieldNamedPreparedStatementImpl) statement;
for (int idx : flinkPreparedStatement.getIndexMapping()[index]) {
// RowData row = val.getRow(index, ((RowType) type).getFieldCount());
// java.sql.Array sqlArray = flinkPreparedStatement.getStatement()
// .getConnection().createArrayOf("bytea", );
flinkPreparedStatement.getStatement().setBytes(idx, new byte[0]);
}
}


@Override
public JdbcDeserializationConverter createInternalConverter(LogicalType type) {
if (sqrlSerializers.containsKey(type.getDefaultConversion())) {
Expand Down
Loading

0 comments on commit 71ecfde

Please sign in to comment.