From 9496cba87fc4fe359bb5c1350422313ea390b1f7 Mon Sep 17 00:00:00 2001 From: Ryanne Dolan Date: Fri, 8 Sep 2023 12:46:18 -0500 Subject: [PATCH] Support longs (#52) --- .../java/com/linkedin/hoptimator/catalog/AvroConverter.java | 5 ++++- .../hoptimator/catalog/builtin/DatagenSchemaFactory.java | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/hoptimator-catalog/src/main/java/com/linkedin/hoptimator/catalog/AvroConverter.java b/hoptimator-catalog/src/main/java/com/linkedin/hoptimator/catalog/AvroConverter.java index cb630d8..ea31f4a 100644 --- a/hoptimator-catalog/src/main/java/com/linkedin/hoptimator/catalog/AvroConverter.java +++ b/hoptimator-catalog/src/main/java/com/linkedin/hoptimator/catalog/AvroConverter.java @@ -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: @@ -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()); diff --git a/hoptimator-catalog/src/main/java/com/linkedin/hoptimator/catalog/builtin/DatagenSchemaFactory.java b/hoptimator-catalog/src/main/java/com/linkedin/hoptimator/catalog/builtin/DatagenSchemaFactory.java index 8cc5667..911aa7f 100644 --- a/hoptimator-catalog/src/main/java/com/linkedin/hoptimator/catalog/builtin/DatagenSchemaFactory.java +++ b/hoptimator-catalog/src/main/java/com/linkedin/hoptimator/catalog/builtin/DatagenSchemaFactory.java @@ -27,7 +27,8 @@ public Schema create(SchemaPlus parentSchema, String name, Map o RelDataTypeFactory typeFactory = new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT); Map 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))