diff --git a/src/main/java/ai/starlake/transpiler/schemas/SampleSchemaProvider.java b/src/main/java/ai/starlake/transpiler/schemas/SampleSchemaProvider.java new file mode 100644 index 0000000..84d4cce --- /dev/null +++ b/src/main/java/ai/starlake/transpiler/schemas/SampleSchemaProvider.java @@ -0,0 +1,37 @@ +package ai.starlake.transpiler.schemas; + + +import java.util.Map; + +public class SampleSchemaProvider implements SchemaProvider { + public Map> getTables() { + return Map.of( + "schema1.table1", Map.of( + "field1", "type1", + "field2", "type2" + ), + "schema2.table1", Map.of( + "field1", "type1", + "field2", "type2" + ) + ); + } + public Map getTable(String schemaName, String tableName) { + return Map.of( + "field1", "type1", + "field2", "type2" + ); + } + public Map> getTables(String tableName) { + return Map.of( + "schema1", Map.of( + "field1", "type1", + "field2", "type2" + ), + "schema2", Map.of( + "field11", "type1", + "field12", "type2" + ) + ); + } +} diff --git a/src/main/java/ai/starlake/transpiler/schemas/SchemaProvider.java b/src/main/java/ai/starlake/transpiler/schemas/SchemaProvider.java new file mode 100644 index 0000000..2fd4d61 --- /dev/null +++ b/src/main/java/ai/starlake/transpiler/schemas/SchemaProvider.java @@ -0,0 +1,34 @@ +package ai.starlake.transpiler.schemas +import java.util.Map; + + + + + +interface SchemaProvider { + /** + * Get all tables in the schema + * @return Map of tables with schema name and table name as key and map of field name and field type as value + */ + Map> getTables(); + + + /** + * Get all fields in the table + * @param schemaName schema name + * @param tableName table name + * @return Map of field name and field type + */ + Map getTable(String schemaName, String tableName); + + /** + * Get table regardless of schema name + * @param tableName table name + * @return Map of schema name where the table is found and map of field name and field type. Returning more than one key means + * the table is found in multiple schemas and the resolution is ambiguous. + * In the future, resolution may be done by jsqltranspiler based on the context. + */ + Map> getTables(String tableName); + +} +