-
Notifications
You must be signed in to change notification settings - Fork 18
Description
Heya Julian,
I'm working on a web playground for Calcite, that I plan on hosting for free so that people can experiment with it. It'll essentially be a web REPL with some pre-loaded data, and the ability to render visualizations of query plans + schema diagrams.
I figured that while I'm at it, it could be nice to add a second input form, which takes Morel expressions, and is bound to the same Calcite context/rootSchema.
Having a bit of difficulty figuring out how to do this though.
I have a singleton object that holds the master schema like below -- I think I need to pass this as a foreignValue to Morel or similar?
// Holds the master schema that contains all datasource schemas and their sub-schemas
object CalciteSchemaService {
val connection: CalciteConnection = initCalciteConnection()
val rootSchema: SchemaPlus = connection.rootSchema
val frameworkConfig: FrameworkConfig = Frameworks.newConfigBuilder()
.defaultSchema(connection.rootSchema)
.parserConfig(SqlParser.config().withCaseSensitive(false))
.build()
val relBuilder: RelBuilder = RelBuilder.create(frameworkConfig)
// <SNIPPED>
}I see this but it's protected:
morel/src/main/java/net/hydromatic/morel/foreign/Calcite.java
Lines 64 to 71 in 0b76fee
| protected Calcite() { | |
| rootSchema = CalciteSchema.createRootSchema(false).plus(); | |
| relBuilder = RelBuilder.create(Frameworks.newConfigBuilder() | |
| .defaultSchema(rootSchema) | |
| .build()); | |
| typeFactory = (JavaTypeFactory) relBuilder.getTypeFactory(); | |
| dataContext = new EmptyDataContext(typeFactory, rootSchema); | |
| } |