Gunnar’s point is a good one. To make it a little more explicit: if the value 
of the the “model” parameter starts with “inline:”, the model is just the rest 
of the string.

As to whether you use models or deal with the SchemaPlus API directly. It’s 
your decision based on how much concurrency control you want to do. If you use 
the SchemaPlus API, you can use the same schema tree for successive requests, 
and even for concurrent requests. But you’d better be sure that one request is 
not mutating the tree while another request is using it. Generating a new model 
string (and hence a new schema tree) for each request is a little less 
efficient but much safer.


> On Jan 3, 2022, at 12:20 PM, Gunnar Morling 
> <[email protected]> wrote:
> 
> Am Mo., 3. Jan. 2022 um 20:44 Uhr schrieb Gavin Ray <[email protected] 
> <mailto:[email protected]>>:
> 
>> @Stamatis
>> 
>> Thank you, I actually did not know that! That's useful information to
>> have =)
>> 
>> @Julian
>> 
>> Is it possible to programmatically generate the JSON model? Why I ask is
>> because part of the functionality I'm trying to mirror is the ability to
>> add
>> data sources dynamically while the app server is running
>> 
>> So you might send a POST /metadata/datasource saying "Here is the info of a
>> new
>> data source I would like you to connect to" And then I need to figure out
>> how to
>> handle creating a Calcite source from it and adding the new datasource +
>> schemas
>> to the global pool of registered ones, if that makes sense
>> 
>> Worst case I could write the JSON file to disk and load from the tempfile I
>> suppose, right?
>> 
> 
> No need for writing to disk, you just can pass in a String representing the
> JSON model. Here's an example:
> 
> 
> https://github.com/moditect/jfr-analytics/blob/main/src/test/java/org/moditect/jfranalytics/JfrSchemaFactoryTest.java#L381-L388
>  
> <https://github.com/moditect/jfr-analytics/blob/main/src/test/java/org/moditect/jfranalytics/JfrSchemaFactoryTest.java#L381-L388>
> 
> Hth,
> 
> --Gunnar
> 
> 
>> 
>> 
>> 
>> On Mon, Jan 3, 2022 at 1:30 PM Julian Hyde <[email protected]> wrote:
>> 
>>>> Will try to figure out how to manually perform the process of creating
>> a
>>>> proper "Connection" object and adding the schemas to it.
>>> 
>>> 
>>> Generally the best way is to write a JSON model, and then create a
>>> connection using ‘jdbc:calcite:…model=...'. For that to work, your
>>> component needs to implement ‘interface SchemaFactory’, i.e. be an
>> adapter.
>>> 
>>> Julian

Reply via email to