You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Shashwat Kumar <sh...@gmail.com> on 2018/10/26 11:45:53 UTC

Provide model.json file from Resources in Jar

Hi,

I am trying to bundle model.json file inside the Java Jar. However Calcite
doesn't seem to have a way to provide path from resources folder, something
like:

connection = DriverManager.getConnection("jdbc:calcite:model=resource:model.json",
"admin", "admin");

It there some way to do so or some existing workaround?


-- 
Regards
Shashwat Kumar

Re: Provide model.json file from Resources in Jar

Posted by Shashwat Kumar <sh...@gmail.com>.
Thank you everyone for the suggestions. For now I have been able to use
"inline" method to do the job. I'll try to try other methods and see if
they are working or not.

Re: Provide model.json file from Resources in Jar

Posted by Andrei Sereda <an...@sereda.cc>.
Agree about long URIs. I was referring to this use case :

String model = ...;
Properties props = new Properties(); prop.put("model", "inline:" +model);
Connection connection = DriverManager.getConnection("jdbc:calcite:", props);

But first check why default resource loading with calcite doesn’t work (it
should).

On Mon, Oct 29, 2018 at 3:14 PM Julian Hyde <jh...@apache.org> wrote:

> Yes, Calcite does support “inline:”
>
> But some folks might not want to generate huge URIs. So IIRC we also have
> ways to read from files in the file system, http resources, and files in
> the classpath (e.g. in jars).
>
> > On Oct 29, 2018, at 12:09 PM, Andrei Sereda <an...@sereda.cc> wrote:
> >
> > I think calcite supports inline: prefix in properties (for models). Try
> to
> > add the following to properties:
> >
> > Properties props = new Properties();
> > prop.put("model", "inline:" + longString);
> >
> >
> > On Mon, Oct 29, 2018 at 3:00 PM Julian Hyde <jh...@apache.org> wrote:
> >
> >> I thought there was a way to read models from jars. I don’t think we
> have
> >> a “resource:” prefix. I think you need to use the path within the jar,
> e.g.
> >> “model=/resources/model.json”.
> >>
> >> Look at the tests, there are probably some clues there.
> >>
> >>> On Oct 26, 2018, at 4:51 AM, ptr.bojko@gmail.com wrote:
> >>>
> >>> Hello,
> >>>
> >>> use:
> >>> connection =
> >> DriverManager.getConnection("jdbc:calcite:",getProperties());
> >>>
> >>> in method getPropertied provide:
> >>> property *user* and *password*
> >>> property *inline* with your schema loaded from resource as a string.
> >>>
> >>> Regards
> >>>
> >>> On Fri, Oct 26, 2018 at 1:46 PM Shashwat Kumar <
> >> shashwatkmr.001@gmail.com>
> >>> wrote:
> >>>
> >>>> Hi,
> >>>>
> >>>> I am trying to bundle model.json file inside the Java Jar. However
> >> Calcite
> >>>> doesn't seem to have a way to provide path from resources folder,
> >> something
> >>>> like:
> >>>>
> >>>> connection =
> >>>> DriverManager.getConnection("jdbc:calcite:model=resource:model.json",
> >>>> "admin", "admin");
> >>>>
> >>>> It there some way to do so or some existing workaround?
> >>>>
> >>>>
> >>>> --
> >>>> Regards
> >>>> Shashwat Kumar
> >>>>
> >>>
> >>>
> >>> --
> >>> Piotr Bojko
> >>> http://about.me/ptr.bojko
> >>
> >>
>
>

Re: Provide model.json file from Resources in Jar

Posted by Julian Hyde <jh...@apache.org>.
Yes, Calcite does support “inline:”

But some folks might not want to generate huge URIs. So IIRC we also have ways to read from files in the file system, http resources, and files in the classpath (e.g. in jars).

> On Oct 29, 2018, at 12:09 PM, Andrei Sereda <an...@sereda.cc> wrote:
> 
> I think calcite supports inline: prefix in properties (for models). Try to
> add the following to properties:
> 
> Properties props = new Properties();
> prop.put("model", "inline:" + longString);
> 
> 
> On Mon, Oct 29, 2018 at 3:00 PM Julian Hyde <jh...@apache.org> wrote:
> 
>> I thought there was a way to read models from jars. I don’t think we have
>> a “resource:” prefix. I think you need to use the path within the jar, e.g.
>> “model=/resources/model.json”.
>> 
>> Look at the tests, there are probably some clues there.
>> 
>>> On Oct 26, 2018, at 4:51 AM, ptr.bojko@gmail.com wrote:
>>> 
>>> Hello,
>>> 
>>> use:
>>> connection =
>> DriverManager.getConnection("jdbc:calcite:",getProperties());
>>> 
>>> in method getPropertied provide:
>>> property *user* and *password*
>>> property *inline* with your schema loaded from resource as a string.
>>> 
>>> Regards
>>> 
>>> On Fri, Oct 26, 2018 at 1:46 PM Shashwat Kumar <
>> shashwatkmr.001@gmail.com>
>>> wrote:
>>> 
>>>> Hi,
>>>> 
>>>> I am trying to bundle model.json file inside the Java Jar. However
>> Calcite
>>>> doesn't seem to have a way to provide path from resources folder,
>> something
>>>> like:
>>>> 
>>>> connection =
>>>> DriverManager.getConnection("jdbc:calcite:model=resource:model.json",
>>>> "admin", "admin");
>>>> 
>>>> It there some way to do so or some existing workaround?
>>>> 
>>>> 
>>>> --
>>>> Regards
>>>> Shashwat Kumar
>>>> 
>>> 
>>> 
>>> --
>>> Piotr Bojko
>>> http://about.me/ptr.bojko
>> 
>> 


Re: Provide model.json file from Resources in Jar

Posted by Andrei Sereda <an...@sereda.cc>.
I think calcite supports inline: prefix in properties (for models). Try to
add the following to properties:

Properties props = new Properties();
prop.put("model", "inline:" + longString);


On Mon, Oct 29, 2018 at 3:00 PM Julian Hyde <jh...@apache.org> wrote:

> I thought there was a way to read models from jars. I don’t think we have
> a “resource:” prefix. I think you need to use the path within the jar, e.g.
> “model=/resources/model.json”.
>
> Look at the tests, there are probably some clues there.
>
> > On Oct 26, 2018, at 4:51 AM, ptr.bojko@gmail.com wrote:
> >
> > Hello,
> >
> > use:
> > connection =
> DriverManager.getConnection("jdbc:calcite:",getProperties());
> >
> > in method getPropertied provide:
> > property *user* and *password*
> > property *inline* with your schema loaded from resource as a string.
> >
> > Regards
> >
> > On Fri, Oct 26, 2018 at 1:46 PM Shashwat Kumar <
> shashwatkmr.001@gmail.com>
> > wrote:
> >
> >> Hi,
> >>
> >> I am trying to bundle model.json file inside the Java Jar. However
> Calcite
> >> doesn't seem to have a way to provide path from resources folder,
> something
> >> like:
> >>
> >> connection =
> >> DriverManager.getConnection("jdbc:calcite:model=resource:model.json",
> >> "admin", "admin");
> >>
> >> It there some way to do so or some existing workaround?
> >>
> >>
> >> --
> >> Regards
> >> Shashwat Kumar
> >>
> >
> >
> > --
> > Piotr Bojko
> > http://about.me/ptr.bojko
>
>

Re: Provide model.json file from Resources in Jar

Posted by Julian Hyde <jh...@apache.org>.
I thought there was a way to read models from jars. I don’t think we have a “resource:” prefix. I think you need to use the path within the jar, e.g. “model=/resources/model.json”.

Look at the tests, there are probably some clues there.

> On Oct 26, 2018, at 4:51 AM, ptr.bojko@gmail.com wrote:
> 
> Hello,
> 
> use:
> connection = DriverManager.getConnection("jdbc:calcite:",getProperties());
> 
> in method getPropertied provide:
> property *user* and *password*
> property *inline* with your schema loaded from resource as a string.
> 
> Regards
> 
> On Fri, Oct 26, 2018 at 1:46 PM Shashwat Kumar <sh...@gmail.com>
> wrote:
> 
>> Hi,
>> 
>> I am trying to bundle model.json file inside the Java Jar. However Calcite
>> doesn't seem to have a way to provide path from resources folder, something
>> like:
>> 
>> connection =
>> DriverManager.getConnection("jdbc:calcite:model=resource:model.json",
>> "admin", "admin");
>> 
>> It there some way to do so or some existing workaround?
>> 
>> 
>> --
>> Regards
>> Shashwat Kumar
>> 
> 
> 
> -- 
> Piotr Bojko
> http://about.me/ptr.bojko


Re: Provide model.json file from Resources in Jar

Posted by "ptr.bojko@gmail.com" <pt...@gmail.com>.
Hello,

use:
connection = DriverManager.getConnection("jdbc:calcite:",getProperties());

in method getPropertied provide:
property *user* and *password*
property *inline* with your schema loaded from resource as a string.

Regards

On Fri, Oct 26, 2018 at 1:46 PM Shashwat Kumar <sh...@gmail.com>
wrote:

> Hi,
>
> I am trying to bundle model.json file inside the Java Jar. However Calcite
> doesn't seem to have a way to provide path from resources folder, something
> like:
>
> connection =
> DriverManager.getConnection("jdbc:calcite:model=resource:model.json",
> "admin", "admin");
>
> It there some way to do so or some existing workaround?
>
>
> --
> Regards
> Shashwat Kumar
>


-- 
Piotr Bojko
http://about.me/ptr.bojko