Skip to content

Commit

Permalink
Merge pull request #6 from starlake-ai/feature/schema-provider
Browse files Browse the repository at this point in the history
WIP: Proposed interface & mock implementation for tests case
  • Loading branch information
manticore-projects authored May 30, 2024
2 parents 8087289 + b23f25c commit 973c253
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package ai.starlake.transpiler.schemas;


import java.util.Map;

public class SampleSchemaProvider implements SchemaProvider {
public Map<String, Map<String, String>> getTables() {
return Map.of(
"schema1.table1", Map.of(
"field1", "type1",
"field2", "type2"
),
"schema2.table1", Map.of(
"field1", "type1",
"field2", "type2"
)
);
}
public Map<String, String> getTable(String schemaName, String tableName) {
return Map.of(
"field1", "type1",
"field2", "type2"
);
}
public Map<String, Map<String, String>> getTables(String tableName) {
return Map.of(
"schema1", Map.of(
"field1", "type1",
"field2", "type2"
),
"schema2", Map.of(
"field11", "type1",
"field12", "type2"
)
);
}
}
34 changes: 34 additions & 0 deletions src/main/java/ai/starlake/transpiler/schemas/SchemaProvider.java
Original file line number Diff line number Diff line change
@@ -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<String, Map<String, String>> getTables();


/**
* Get all fields in the table
* @param schemaName schema name
* @param tableName table name
* @return Map of field name and field type
*/
Map<String, String> 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<String, Map<String, String>> getTables(String tableName);

}

0 comments on commit 973c253

Please sign in to comment.