Skip to content

Commit

Permalink
Support longs (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryannedolan authored Sep 8, 2023
1 parent 84b3430 commit 9496cba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public static Schema avro(String namespace, String name, RelDataType dataType) {
switch (dataType.getSqlTypeName()) {
case INTEGER:
return createAvroTypeWithNullability(Schema.Type.INT, dataType.isNullable());
case BIGINT:
return createAvroTypeWithNullability(Schema.Type.LONG, dataType.isNullable());
case VARCHAR:
return createAvroTypeWithNullability(Schema.Type.STRING, dataType.isNullable());
case FLOAT:
Expand Down Expand Up @@ -72,9 +74,10 @@ public static RelDataType rel(Schema schema, RelDataTypeFactory typeFactory) {
.filter(x -> x.getValue().getSqlTypeName() != unknown.getSqlTypeName())
.collect(Collectors.toList()));
case INT:
case LONG:
// schema.isNullable() should be false for basic types iiuc
return createRelTypeWithNullability(typeFactory, SqlTypeName.INTEGER, schema.isNullable());
case LONG:
return createRelTypeWithNullability(typeFactory, SqlTypeName.BIGINT, schema.isNullable());
case ENUM:
case STRING:
return createRelTypeWithNullability(typeFactory, SqlTypeName.VARCHAR, schema.isNullable());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public Schema create(SchemaPlus parentSchema, String name, Map<String, Object> o
RelDataTypeFactory typeFactory = new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
Map<String, HopTable> datagenTables = new HashMap<>();
datagenTables.put("PERSON", new HopTable("DATAGEN", "PERSON", (new RelDataTypeFactory.Builder(typeFactory))
.add("NAME", SqlTypeName.VARCHAR).add("AGE", SqlTypeName.INTEGER).build(), ConfigProvider.empty()
.add("NAME", SqlTypeName.VARCHAR).add("AGE", SqlTypeName.INTEGER)
.add("EMPID", SqlTypeName.BIGINT).build(), ConfigProvider.empty()
.with("connector", "datagen").with("number-of-rows", "10").with("fields.AGE.min", "0")
.with("fields.AGE.max", "100").with("fields.NAME.length", "5").config("PERSON")));
datagenTables.put("COMPANY", new HopTable("DATAGEN", "COMPANY", (new RelDataTypeFactory.Builder(typeFactory))
Expand Down

0 comments on commit 9496cba

Please sign in to comment.