-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from starlake-ai/feature/schema-provider
WIP: Proposed interface & mock implementation for tests case
- Loading branch information
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/main/java/ai/starlake/transpiler/schemas/SampleSchemaProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
34
src/main/java/ai/starlake/transpiler/schemas/SchemaProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} | ||
|