You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@metamodel.apache.org by Alberto Rodriguez <ar...@gmail.com> on 2014/09/02 16:54:24 UTC

Problem executing string-format queries

Hi all,

I have just come across your awesome library and am integrating it in my
project.

I have just written a couple of tests and noticed that I can execute a
string-format query against a JdbcDataContext whereas I am getting an
IllegarArgumentException ( Expression-based filters cannot be manually
evaluated) when I execute the same query using a CsvDataContext.

This is working fine:

val dataContext = DataContextFactory.createJdbcDataContext(connection)
        val dataSet = dataContext.executeQuery("""SELECT * FROM
public.data_sources WHERE TYPE='rest'""")

This is returning the exception:

 val dataContext = DataContextFactory.createCsvDataContext(csvFile)
WHERE name='rojo'""")

Is there any way of executing string queries against all the datacontext
types?

Thank you!

Re: Problem executing string-format queries

Posted by Kasper Sørensen <i....@gmail.com>.
Hi Alberto,

I agree. Having an ES module for MetaModel would be very cool. If you wanna
take a stab at it we will surely do our best to help!

Kasper
Den 03/09/2014 10.51 skrev "Alberto Rodriguez" <ar...@gmail.com>:

> Hi Hans,
>
> I have been taking a look at the DataCleaner website and it looks
> promising. Correct me if I am wrong but I think that I would need a
> DataCleaner instance running to take advantage of the elasticsearch
> extension. I don't want to have any external dependencies in my webapp,
> ideally I would like to query my elasticsearch cluster the same way that I
> will query the other datasources. IMHO you can see ElasticSearch as another
> data source.
>
> Kind regards,
>
> Alberto
>
>
> 2014-09-03 10:14 GMT+02:00 Hans Drexler <Ha...@humaninference.com>:
>
> > Hi Rodrigo,
> >
> > DataCleaner already has a plugin for ElasticSearch:
> >
> > http://datacleaner.org/extension/ElasticSearch-for-DataCleaner
> >
> > This extension allows to index records to ElasticSearch. It also contains
> > an ID lookup component and a Search component.  I don't think there is an
> > ElasticSearch MetaModel coupling, though.
> >
> > Kind regards,
> >
> > Hans
> >
> > -----Original Message-----
> > From: Alberto Rodriguez [mailto:ardlema@gmail.com]
> > Sent: Wednesday, September 03, 2014 10:04 AM
> > To: dev@metamodel.incubator.apache.org
> > Subject: Re: Problem executing string-format queries
> >
> > Hi guys!
> >
> > First of all thank you very much for your quick responses. I have just
> > tried the bug workaround and it works like a charm, thank you Kasper!!!
> >
> > I think you are creating and awesome library so please keep working on
> it!
> >
> > By the way, one of the datasources we would like to include within our
> > application is ElasticSearch <http://www.elasticsearch.org/>, are you
> > thinking about including a module for it? If not I would be happy to
> > contribute to your project by trying to add it.
> >
> > Kind regards,
> >
> > Alberto
> >
> >
> > 2014-09-03 8:53 GMT+02:00 Hans Drexler <Hans.Drexler@humaninference.com
> >:
> >
> > > Hi Rodriguez,
> > >
> > > I see the master of everything metamodel has already cracked your
> > problem.
> > > Have a great time using MetaModel!
> > >
> > > Hans
> > >
> > > -----Original Message-----
> > > From: Alberto Rodriguez [mailto:ardlema@gmail.com]
> > > Sent: Tuesday, September 02, 2014 4:54 PM
> > > To: dev@metamodel.incubator.apache.org
> > > Subject: Problem executing string-format queries
> > >
> > > Hi all,
> > >
> > > I have just come across your awesome library and am integrating it in
> > > my project.
> > >
> > > I have just written a couple of tests and noticed that I can execute a
> > > string-format query against a JdbcDataContext whereas I am getting an
> > > IllegarArgumentException ( Expression-based filters cannot be manually
> > > evaluated) when I execute the same query using a CsvDataContext.
> > >
> > > This is working fine:
> > >
> > > val dataContext = DataContextFactory.createJdbcDataContext(connection)
> > >         val dataSet = dataContext.executeQuery("""SELECT * FROM
> > > public.data_sources WHERE TYPE='rest'""")
> > >
> > > This is returning the exception:
> > >
> > >  val dataContext = DataContextFactory.createCsvDataContext(csvFile)
> > > WHERE name='rojo'""")
> > >
> > > Is there any way of executing string queries against all the
> > > datacontext types?
> > >
> > > Thank you!
> > >
> >
>

Re: Problem executing string-format queries

Posted by Alberto Rodriguez <ar...@gmail.com>.
Hi Hans,

I have been taking a look at the DataCleaner website and it looks
promising. Correct me if I am wrong but I think that I would need a
DataCleaner instance running to take advantage of the elasticsearch
extension. I don't want to have any external dependencies in my webapp,
ideally I would like to query my elasticsearch cluster the same way that I
will query the other datasources. IMHO you can see ElasticSearch as another
data source.

Kind regards,

Alberto


2014-09-03 10:14 GMT+02:00 Hans Drexler <Ha...@humaninference.com>:

> Hi Rodrigo,
>
> DataCleaner already has a plugin for ElasticSearch:
>
> http://datacleaner.org/extension/ElasticSearch-for-DataCleaner
>
> This extension allows to index records to ElasticSearch. It also contains
> an ID lookup component and a Search component.  I don't think there is an
> ElasticSearch MetaModel coupling, though.
>
> Kind regards,
>
> Hans
>
> -----Original Message-----
> From: Alberto Rodriguez [mailto:ardlema@gmail.com]
> Sent: Wednesday, September 03, 2014 10:04 AM
> To: dev@metamodel.incubator.apache.org
> Subject: Re: Problem executing string-format queries
>
> Hi guys!
>
> First of all thank you very much for your quick responses. I have just
> tried the bug workaround and it works like a charm, thank you Kasper!!!
>
> I think you are creating and awesome library so please keep working on it!
>
> By the way, one of the datasources we would like to include within our
> application is ElasticSearch <http://www.elasticsearch.org/>, are you
> thinking about including a module for it? If not I would be happy to
> contribute to your project by trying to add it.
>
> Kind regards,
>
> Alberto
>
>
> 2014-09-03 8:53 GMT+02:00 Hans Drexler <Ha...@humaninference.com>:
>
> > Hi Rodriguez,
> >
> > I see the master of everything metamodel has already cracked your
> problem.
> > Have a great time using MetaModel!
> >
> > Hans
> >
> > -----Original Message-----
> > From: Alberto Rodriguez [mailto:ardlema@gmail.com]
> > Sent: Tuesday, September 02, 2014 4:54 PM
> > To: dev@metamodel.incubator.apache.org
> > Subject: Problem executing string-format queries
> >
> > Hi all,
> >
> > I have just come across your awesome library and am integrating it in
> > my project.
> >
> > I have just written a couple of tests and noticed that I can execute a
> > string-format query against a JdbcDataContext whereas I am getting an
> > IllegarArgumentException ( Expression-based filters cannot be manually
> > evaluated) when I execute the same query using a CsvDataContext.
> >
> > This is working fine:
> >
> > val dataContext = DataContextFactory.createJdbcDataContext(connection)
> >         val dataSet = dataContext.executeQuery("""SELECT * FROM
> > public.data_sources WHERE TYPE='rest'""")
> >
> > This is returning the exception:
> >
> >  val dataContext = DataContextFactory.createCsvDataContext(csvFile)
> > WHERE name='rojo'""")
> >
> > Is there any way of executing string queries against all the
> > datacontext types?
> >
> > Thank you!
> >
>

RE: Problem executing string-format queries

Posted by Hans Drexler <Ha...@HumanInference.com>.
Hi Rodrigo,

DataCleaner already has a plugin for ElasticSearch:

http://datacleaner.org/extension/ElasticSearch-for-DataCleaner

This extension allows to index records to ElasticSearch. It also contains an ID lookup component and a Search component.  I don't think there is an ElasticSearch MetaModel coupling, though. 

Kind regards,

Hans

-----Original Message-----
From: Alberto Rodriguez [mailto:ardlema@gmail.com] 
Sent: Wednesday, September 03, 2014 10:04 AM
To: dev@metamodel.incubator.apache.org
Subject: Re: Problem executing string-format queries

Hi guys!

First of all thank you very much for your quick responses. I have just tried the bug workaround and it works like a charm, thank you Kasper!!!

I think you are creating and awesome library so please keep working on it!

By the way, one of the datasources we would like to include within our application is ElasticSearch <http://www.elasticsearch.org/>, are you thinking about including a module for it? If not I would be happy to contribute to your project by trying to add it.

Kind regards,

Alberto


2014-09-03 8:53 GMT+02:00 Hans Drexler <Ha...@humaninference.com>:

> Hi Rodriguez,
>
> I see the master of everything metamodel has already cracked your problem.
> Have a great time using MetaModel!
>
> Hans
>
> -----Original Message-----
> From: Alberto Rodriguez [mailto:ardlema@gmail.com]
> Sent: Tuesday, September 02, 2014 4:54 PM
> To: dev@metamodel.incubator.apache.org
> Subject: Problem executing string-format queries
>
> Hi all,
>
> I have just come across your awesome library and am integrating it in 
> my project.
>
> I have just written a couple of tests and noticed that I can execute a 
> string-format query against a JdbcDataContext whereas I am getting an 
> IllegarArgumentException ( Expression-based filters cannot be manually
> evaluated) when I execute the same query using a CsvDataContext.
>
> This is working fine:
>
> val dataContext = DataContextFactory.createJdbcDataContext(connection)
>         val dataSet = dataContext.executeQuery("""SELECT * FROM 
> public.data_sources WHERE TYPE='rest'""")
>
> This is returning the exception:
>
>  val dataContext = DataContextFactory.createCsvDataContext(csvFile)
> WHERE name='rojo'""")
>
> Is there any way of executing string queries against all the 
> datacontext types?
>
> Thank you!
>

Re: Problem executing string-format queries

Posted by Alberto Rodriguez <ar...@gmail.com>.
Hi guys!

First of all thank you very much for your quick responses. I have just
tried the bug workaround and it works like a charm, thank you Kasper!!!

I think you are creating and awesome library so please keep working on it!

By the way, one of the datasources we would like to include within our
application is ElasticSearch <http://www.elasticsearch.org/>, are you
thinking about including a module for it? If not I would be happy to
contribute to your project by trying to add it.

Kind regards,

Alberto


2014-09-03 8:53 GMT+02:00 Hans Drexler <Ha...@humaninference.com>:

> Hi Rodriguez,
>
> I see the master of everything metamodel has already cracked your problem.
> Have a great time using MetaModel!
>
> Hans
>
> -----Original Message-----
> From: Alberto Rodriguez [mailto:ardlema@gmail.com]
> Sent: Tuesday, September 02, 2014 4:54 PM
> To: dev@metamodel.incubator.apache.org
> Subject: Problem executing string-format queries
>
> Hi all,
>
> I have just come across your awesome library and am integrating it in my
> project.
>
> I have just written a couple of tests and noticed that I can execute a
> string-format query against a JdbcDataContext whereas I am getting an
> IllegarArgumentException ( Expression-based filters cannot be manually
> evaluated) when I execute the same query using a CsvDataContext.
>
> This is working fine:
>
> val dataContext = DataContextFactory.createJdbcDataContext(connection)
>         val dataSet = dataContext.executeQuery("""SELECT * FROM
> public.data_sources WHERE TYPE='rest'""")
>
> This is returning the exception:
>
>  val dataContext = DataContextFactory.createCsvDataContext(csvFile)
> WHERE name='rojo'""")
>
> Is there any way of executing string queries against all the datacontext
> types?
>
> Thank you!
>

RE: Problem executing string-format queries

Posted by Hans Drexler <Ha...@HumanInference.com>.
Hi Rodriguez,

I see the master of everything metamodel has already cracked your problem. Have a great time using MetaModel!

Hans

-----Original Message-----
From: Alberto Rodriguez [mailto:ardlema@gmail.com] 
Sent: Tuesday, September 02, 2014 4:54 PM
To: dev@metamodel.incubator.apache.org
Subject: Problem executing string-format queries

Hi all,

I have just come across your awesome library and am integrating it in my project.

I have just written a couple of tests and noticed that I can execute a string-format query against a JdbcDataContext whereas I am getting an IllegarArgumentException ( Expression-based filters cannot be manually
evaluated) when I execute the same query using a CsvDataContext.

This is working fine:

val dataContext = DataContextFactory.createJdbcDataContext(connection)
        val dataSet = dataContext.executeQuery("""SELECT * FROM public.data_sources WHERE TYPE='rest'""")

This is returning the exception:

 val dataContext = DataContextFactory.createCsvDataContext(csvFile)
WHERE name='rojo'""")

Is there any way of executing string queries against all the datacontext types?

Thank you!

Re: Problem executing string-format queries

Posted by Kasper Sørensen <i....@gmail.com>.
Hi Alberto,

I did some debugging into this issue, and it seems that there is both an
issue and a workaround :-)

1) The issue is that the query parser seems to not properly process a token
like "id='1'" where there are no spaces around the equals sign (=). This is
obviously a bug, and I will report it asap.

2) The workaround for now is to make sure you add spaces around the '='
sign, so that it becomes "id = '1'".

I have this reproduced in a unittest so I will post that to JIRA in a jiffy.

Kasper


2014-09-02 18:01 GMT+02:00 Alberto Rodriguez <ar...@gmail.com>:

> Sure! This is the toSql method output for the CSV query:
>
> SELECT testdata.csv.name, testdata.csv.value FROM resources.testdata.csv
> WHERE name='rojo'
>
> And this is the one for the json query:
>
> SELECT testdata.json.id, testdata.json.name, testdata.json.properties,
> testdata.json.query, testdata.json.type FROM resources.testdata.json WHERE
> id='1'
>
>
> 2014-09-02 17:42 GMT+02:00 Kasper Sørensen <i.am.kasper.sorensen@gmail.com
> >:
>
> > I agree and we have a similar need actually. So it needs to just work.
> > Surprised if it doesn't. Can you try to print the toSql method of the
> > query?
> > Den 02/09/2014 17.36 skrev "Alberto Rodriguez" <ar...@gmail.com>:
> >
> > > Yes they both exist. I have created the query using the query builder
> and
> > > they work fine.
> > >
> > > CSV:
> > >
> > > val dataContext = DataContextFactory.createCsvDataContext(csvFile)
> > > val dataSet =
> > >
> > >
> >
> dataContext.query().from(fileName).selectAll().where("name").eq("rojo").execute()
> > >
> > > JSON:
> > >
> > > val dataContext = DataContextFactory.createJsonDataContext(jsonFile)
> > > val dataSet =
> > >
> >
> dataContext.query().from(fileName).selectAll().where("id").eq(1).execute()
> > >
> > > I am really interested in using the executeQuery method with a string
> > query
> > > because I am developing a web application and I am getting the query
> > > directly from the user. It would be awesome if I could call the
> > > executeQuery method passing the string query.
> > >
> > > Best regards,
> > >
> > > Alberto
> > >
> > >
> > > 2014-09-02 17:19 GMT+02:00 Kasper Sørensen <
> > i.am.kasper.sorensen@gmail.com
> > > >:
> > >
> > > > Can you verify (using getDefaultSchema, getTable(0), getColumnByName)
> > > that
> > > > these columns actually exist. If not a string query would not be
> parsed
> > > > properly. You could also be using the typed query builder to make it
> > > safer.
> > > > Den 02/09/2014 17.13 skrev "Alberto Rodriguez" <ar...@gmail.com>:
> > > >
> > > > > Hi Hans,
> > > > >
> > > > > You are right my code snippet was not complete, here it is:
> > > > >
> > > > > val dataContext = DataContextFactory.createCsvDataContext(csvFile)
> > > > > val dataSet = dataContext.executeQuery("""SELECT * FROM
> testdata.csv
> > > > WHERE
> > > > > name='rojo'""")
> > > > >
> > > > > I have just tested the same with a JsonDataContext and getting the
> > same
> > > > > exception:
> > > > >
> > > > > val fileName = "testdata.json"
> > > > > val jsonFile = new File(s"test/resources/$fileName")
> > > > > val dataContext =
> DataContextFactory.createJsonDataContext(jsonFile)
> > > > > val dataSet = dataContext.executeQuery("""SELECT * FROM
> testdata.json
> > > > WHERE
> > > > > id='1'""")
> > > > >
> > > > > I am afraid that you can only include 'WHERE' clauses within a
> > > > executeQuery
> > > > > method (with a string format query) using the JdbcDataContext.
> > > > >
> > > > > Kind regards,
> > > > >
> > > > > Alberto
> > > > >
> > > > >
> > > > > 2014-09-02 16:59 GMT+02:00 Hans Drexler <
> > > Hans.Drexler@humaninference.com
> > > > >:
> > > > >
> > > > > > Hi Alberto,
> > > > > >
> > > > > > I am not the biggest expert, but I think queries should work
> > against
> > > > all
> > > > > > types of data contexts. That is one leading principle of
> MetaModel.
> > > > From
> > > > > > your code example, it seems the second code snippet (with the csv
> > > data
> > > > > > context) is not complete. There is not a complete query in it.
> Can
> > > you
> > > > > > double check your code and post? Maybe then we can help better.
> > > > > >
> > > > > > Kind regards,
> > > > > >
> > > > > > Hans Drexler
> > > > > >
> > > > > > -----Original Message-----
> > > > > > From: Alberto Rodriguez [mailto:ardlema@gmail.com]
> > > > > > Sent: Tuesday, September 02, 2014 4:54 PM
> > > > > > To: dev@metamodel.incubator.apache.org
> > > > > > Subject: Problem executing string-format queries
> > > > > >
> > > > > > Hi all,
> > > > > >
> > > > > > I have just come across your awesome library and am integrating
> it
> > in
> > > > my
> > > > > > project.
> > > > > >
> > > > > > I have just written a couple of tests and noticed that I can
> > execute
> > > a
> > > > > > string-format query against a JdbcDataContext whereas I am
> getting
> > an
> > > > > > IllegarArgumentException ( Expression-based filters cannot be
> > > manually
> > > > > > evaluated) when I execute the same query using a CsvDataContext.
> > > > > >
> > > > > > This is working fine:
> > > > > >
> > > > > > val dataContext =
> > > DataContextFactory.createJdbcDataContext(connection)
> > > > > >         val dataSet = dataContext.executeQuery("""SELECT * FROM
> > > > > > public.data_sources WHERE TYPE='rest'""")
> > > > > >
> > > > > > This is returning the exception:
> > > > > >
> > > > > >  val dataContext =
> DataContextFactory.createCsvDataContext(csvFile)
> > > > > > WHERE name='rojo'""")
> > > > > >
> > > > > > Is there any way of executing string queries against all the
> > > > datacontext
> > > > > > types?
> > > > > >
> > > > > > Thank you!
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: Problem executing string-format queries

Posted by Alberto Rodriguez <ar...@gmail.com>.
Sure! This is the toSql method output for the CSV query:

SELECT testdata.csv.name, testdata.csv.value FROM resources.testdata.csv
WHERE name='rojo'

And this is the one for the json query:

SELECT testdata.json.id, testdata.json.name, testdata.json.properties,
testdata.json.query, testdata.json.type FROM resources.testdata.json WHERE
id='1'


2014-09-02 17:42 GMT+02:00 Kasper Sørensen <i....@gmail.com>:

> I agree and we have a similar need actually. So it needs to just work.
> Surprised if it doesn't. Can you try to print the toSql method of the
> query?
> Den 02/09/2014 17.36 skrev "Alberto Rodriguez" <ar...@gmail.com>:
>
> > Yes they both exist. I have created the query using the query builder and
> > they work fine.
> >
> > CSV:
> >
> > val dataContext = DataContextFactory.createCsvDataContext(csvFile)
> > val dataSet =
> >
> >
> dataContext.query().from(fileName).selectAll().where("name").eq("rojo").execute()
> >
> > JSON:
> >
> > val dataContext = DataContextFactory.createJsonDataContext(jsonFile)
> > val dataSet =
> >
> dataContext.query().from(fileName).selectAll().where("id").eq(1).execute()
> >
> > I am really interested in using the executeQuery method with a string
> query
> > because I am developing a web application and I am getting the query
> > directly from the user. It would be awesome if I could call the
> > executeQuery method passing the string query.
> >
> > Best regards,
> >
> > Alberto
> >
> >
> > 2014-09-02 17:19 GMT+02:00 Kasper Sørensen <
> i.am.kasper.sorensen@gmail.com
> > >:
> >
> > > Can you verify (using getDefaultSchema, getTable(0), getColumnByName)
> > that
> > > these columns actually exist. If not a string query would not be parsed
> > > properly. You could also be using the typed query builder to make it
> > safer.
> > > Den 02/09/2014 17.13 skrev "Alberto Rodriguez" <ar...@gmail.com>:
> > >
> > > > Hi Hans,
> > > >
> > > > You are right my code snippet was not complete, here it is:
> > > >
> > > > val dataContext = DataContextFactory.createCsvDataContext(csvFile)
> > > > val dataSet = dataContext.executeQuery("""SELECT * FROM testdata.csv
> > > WHERE
> > > > name='rojo'""")
> > > >
> > > > I have just tested the same with a JsonDataContext and getting the
> same
> > > > exception:
> > > >
> > > > val fileName = "testdata.json"
> > > > val jsonFile = new File(s"test/resources/$fileName")
> > > > val dataContext = DataContextFactory.createJsonDataContext(jsonFile)
> > > > val dataSet = dataContext.executeQuery("""SELECT * FROM testdata.json
> > > WHERE
> > > > id='1'""")
> > > >
> > > > I am afraid that you can only include 'WHERE' clauses within a
> > > executeQuery
> > > > method (with a string format query) using the JdbcDataContext.
> > > >
> > > > Kind regards,
> > > >
> > > > Alberto
> > > >
> > > >
> > > > 2014-09-02 16:59 GMT+02:00 Hans Drexler <
> > Hans.Drexler@humaninference.com
> > > >:
> > > >
> > > > > Hi Alberto,
> > > > >
> > > > > I am not the biggest expert, but I think queries should work
> against
> > > all
> > > > > types of data contexts. That is one leading principle of MetaModel.
> > > From
> > > > > your code example, it seems the second code snippet (with the csv
> > data
> > > > > context) is not complete. There is not a complete query in it. Can
> > you
> > > > > double check your code and post? Maybe then we can help better.
> > > > >
> > > > > Kind regards,
> > > > >
> > > > > Hans Drexler
> > > > >
> > > > > -----Original Message-----
> > > > > From: Alberto Rodriguez [mailto:ardlema@gmail.com]
> > > > > Sent: Tuesday, September 02, 2014 4:54 PM
> > > > > To: dev@metamodel.incubator.apache.org
> > > > > Subject: Problem executing string-format queries
> > > > >
> > > > > Hi all,
> > > > >
> > > > > I have just come across your awesome library and am integrating it
> in
> > > my
> > > > > project.
> > > > >
> > > > > I have just written a couple of tests and noticed that I can
> execute
> > a
> > > > > string-format query against a JdbcDataContext whereas I am getting
> an
> > > > > IllegarArgumentException ( Expression-based filters cannot be
> > manually
> > > > > evaluated) when I execute the same query using a CsvDataContext.
> > > > >
> > > > > This is working fine:
> > > > >
> > > > > val dataContext =
> > DataContextFactory.createJdbcDataContext(connection)
> > > > >         val dataSet = dataContext.executeQuery("""SELECT * FROM
> > > > > public.data_sources WHERE TYPE='rest'""")
> > > > >
> > > > > This is returning the exception:
> > > > >
> > > > >  val dataContext = DataContextFactory.createCsvDataContext(csvFile)
> > > > > WHERE name='rojo'""")
> > > > >
> > > > > Is there any way of executing string queries against all the
> > > datacontext
> > > > > types?
> > > > >
> > > > > Thank you!
> > > > >
> > > >
> > >
> >
>

Re: Problem executing string-format queries

Posted by Kasper Sørensen <i....@gmail.com>.
I agree and we have a similar need actually. So it needs to just work.
Surprised if it doesn't. Can you try to print the toSql method of the query?
Den 02/09/2014 17.36 skrev "Alberto Rodriguez" <ar...@gmail.com>:

> Yes they both exist. I have created the query using the query builder and
> they work fine.
>
> CSV:
>
> val dataContext = DataContextFactory.createCsvDataContext(csvFile)
> val dataSet =
>
> dataContext.query().from(fileName).selectAll().where("name").eq("rojo").execute()
>
> JSON:
>
> val dataContext = DataContextFactory.createJsonDataContext(jsonFile)
> val dataSet =
> dataContext.query().from(fileName).selectAll().where("id").eq(1).execute()
>
> I am really interested in using the executeQuery method with a string query
> because I am developing a web application and I am getting the query
> directly from the user. It would be awesome if I could call the
> executeQuery method passing the string query.
>
> Best regards,
>
> Alberto
>
>
> 2014-09-02 17:19 GMT+02:00 Kasper Sørensen <i.am.kasper.sorensen@gmail.com
> >:
>
> > Can you verify (using getDefaultSchema, getTable(0), getColumnByName)
> that
> > these columns actually exist. If not a string query would not be parsed
> > properly. You could also be using the typed query builder to make it
> safer.
> > Den 02/09/2014 17.13 skrev "Alberto Rodriguez" <ar...@gmail.com>:
> >
> > > Hi Hans,
> > >
> > > You are right my code snippet was not complete, here it is:
> > >
> > > val dataContext = DataContextFactory.createCsvDataContext(csvFile)
> > > val dataSet = dataContext.executeQuery("""SELECT * FROM testdata.csv
> > WHERE
> > > name='rojo'""")
> > >
> > > I have just tested the same with a JsonDataContext and getting the same
> > > exception:
> > >
> > > val fileName = "testdata.json"
> > > val jsonFile = new File(s"test/resources/$fileName")
> > > val dataContext = DataContextFactory.createJsonDataContext(jsonFile)
> > > val dataSet = dataContext.executeQuery("""SELECT * FROM testdata.json
> > WHERE
> > > id='1'""")
> > >
> > > I am afraid that you can only include 'WHERE' clauses within a
> > executeQuery
> > > method (with a string format query) using the JdbcDataContext.
> > >
> > > Kind regards,
> > >
> > > Alberto
> > >
> > >
> > > 2014-09-02 16:59 GMT+02:00 Hans Drexler <
> Hans.Drexler@humaninference.com
> > >:
> > >
> > > > Hi Alberto,
> > > >
> > > > I am not the biggest expert, but I think queries should work against
> > all
> > > > types of data contexts. That is one leading principle of MetaModel.
> > From
> > > > your code example, it seems the second code snippet (with the csv
> data
> > > > context) is not complete. There is not a complete query in it. Can
> you
> > > > double check your code and post? Maybe then we can help better.
> > > >
> > > > Kind regards,
> > > >
> > > > Hans Drexler
> > > >
> > > > -----Original Message-----
> > > > From: Alberto Rodriguez [mailto:ardlema@gmail.com]
> > > > Sent: Tuesday, September 02, 2014 4:54 PM
> > > > To: dev@metamodel.incubator.apache.org
> > > > Subject: Problem executing string-format queries
> > > >
> > > > Hi all,
> > > >
> > > > I have just come across your awesome library and am integrating it in
> > my
> > > > project.
> > > >
> > > > I have just written a couple of tests and noticed that I can execute
> a
> > > > string-format query against a JdbcDataContext whereas I am getting an
> > > > IllegarArgumentException ( Expression-based filters cannot be
> manually
> > > > evaluated) when I execute the same query using a CsvDataContext.
> > > >
> > > > This is working fine:
> > > >
> > > > val dataContext =
> DataContextFactory.createJdbcDataContext(connection)
> > > >         val dataSet = dataContext.executeQuery("""SELECT * FROM
> > > > public.data_sources WHERE TYPE='rest'""")
> > > >
> > > > This is returning the exception:
> > > >
> > > >  val dataContext = DataContextFactory.createCsvDataContext(csvFile)
> > > > WHERE name='rojo'""")
> > > >
> > > > Is there any way of executing string queries against all the
> > datacontext
> > > > types?
> > > >
> > > > Thank you!
> > > >
> > >
> >
>

Re: Problem executing string-format queries

Posted by Alberto Rodriguez <ar...@gmail.com>.
Yes they both exist. I have created the query using the query builder and
they work fine.

CSV:

val dataContext = DataContextFactory.createCsvDataContext(csvFile)
val dataSet =
dataContext.query().from(fileName).selectAll().where("name").eq("rojo").execute()

JSON:

val dataContext = DataContextFactory.createJsonDataContext(jsonFile)
val dataSet =
dataContext.query().from(fileName).selectAll().where("id").eq(1).execute()

I am really interested in using the executeQuery method with a string query
because I am developing a web application and I am getting the query
directly from the user. It would be awesome if I could call the
executeQuery method passing the string query.

Best regards,

Alberto


2014-09-02 17:19 GMT+02:00 Kasper Sørensen <i....@gmail.com>:

> Can you verify (using getDefaultSchema, getTable(0), getColumnByName) that
> these columns actually exist. If not a string query would not be parsed
> properly. You could also be using the typed query builder to make it safer.
> Den 02/09/2014 17.13 skrev "Alberto Rodriguez" <ar...@gmail.com>:
>
> > Hi Hans,
> >
> > You are right my code snippet was not complete, here it is:
> >
> > val dataContext = DataContextFactory.createCsvDataContext(csvFile)
> > val dataSet = dataContext.executeQuery("""SELECT * FROM testdata.csv
> WHERE
> > name='rojo'""")
> >
> > I have just tested the same with a JsonDataContext and getting the same
> > exception:
> >
> > val fileName = "testdata.json"
> > val jsonFile = new File(s"test/resources/$fileName")
> > val dataContext = DataContextFactory.createJsonDataContext(jsonFile)
> > val dataSet = dataContext.executeQuery("""SELECT * FROM testdata.json
> WHERE
> > id='1'""")
> >
> > I am afraid that you can only include 'WHERE' clauses within a
> executeQuery
> > method (with a string format query) using the JdbcDataContext.
> >
> > Kind regards,
> >
> > Alberto
> >
> >
> > 2014-09-02 16:59 GMT+02:00 Hans Drexler <Hans.Drexler@humaninference.com
> >:
> >
> > > Hi Alberto,
> > >
> > > I am not the biggest expert, but I think queries should work against
> all
> > > types of data contexts. That is one leading principle of MetaModel.
> From
> > > your code example, it seems the second code snippet (with the csv data
> > > context) is not complete. There is not a complete query in it. Can you
> > > double check your code and post? Maybe then we can help better.
> > >
> > > Kind regards,
> > >
> > > Hans Drexler
> > >
> > > -----Original Message-----
> > > From: Alberto Rodriguez [mailto:ardlema@gmail.com]
> > > Sent: Tuesday, September 02, 2014 4:54 PM
> > > To: dev@metamodel.incubator.apache.org
> > > Subject: Problem executing string-format queries
> > >
> > > Hi all,
> > >
> > > I have just come across your awesome library and am integrating it in
> my
> > > project.
> > >
> > > I have just written a couple of tests and noticed that I can execute a
> > > string-format query against a JdbcDataContext whereas I am getting an
> > > IllegarArgumentException ( Expression-based filters cannot be manually
> > > evaluated) when I execute the same query using a CsvDataContext.
> > >
> > > This is working fine:
> > >
> > > val dataContext = DataContextFactory.createJdbcDataContext(connection)
> > >         val dataSet = dataContext.executeQuery("""SELECT * FROM
> > > public.data_sources WHERE TYPE='rest'""")
> > >
> > > This is returning the exception:
> > >
> > >  val dataContext = DataContextFactory.createCsvDataContext(csvFile)
> > > WHERE name='rojo'""")
> > >
> > > Is there any way of executing string queries against all the
> datacontext
> > > types?
> > >
> > > Thank you!
> > >
> >
>

Re: Problem executing string-format queries

Posted by Kasper Sørensen <i....@gmail.com>.
Can you verify (using getDefaultSchema, getTable(0), getColumnByName) that
these columns actually exist. If not a string query would not be parsed
properly. You could also be using the typed query builder to make it safer.
Den 02/09/2014 17.13 skrev "Alberto Rodriguez" <ar...@gmail.com>:

> Hi Hans,
>
> You are right my code snippet was not complete, here it is:
>
> val dataContext = DataContextFactory.createCsvDataContext(csvFile)
> val dataSet = dataContext.executeQuery("""SELECT * FROM testdata.csv WHERE
> name='rojo'""")
>
> I have just tested the same with a JsonDataContext and getting the same
> exception:
>
> val fileName = "testdata.json"
> val jsonFile = new File(s"test/resources/$fileName")
> val dataContext = DataContextFactory.createJsonDataContext(jsonFile)
> val dataSet = dataContext.executeQuery("""SELECT * FROM testdata.json WHERE
> id='1'""")
>
> I am afraid that you can only include 'WHERE' clauses within a executeQuery
> method (with a string format query) using the JdbcDataContext.
>
> Kind regards,
>
> Alberto
>
>
> 2014-09-02 16:59 GMT+02:00 Hans Drexler <Ha...@humaninference.com>:
>
> > Hi Alberto,
> >
> > I am not the biggest expert, but I think queries should work against all
> > types of data contexts. That is one leading principle of MetaModel. From
> > your code example, it seems the second code snippet (with the csv data
> > context) is not complete. There is not a complete query in it. Can you
> > double check your code and post? Maybe then we can help better.
> >
> > Kind regards,
> >
> > Hans Drexler
> >
> > -----Original Message-----
> > From: Alberto Rodriguez [mailto:ardlema@gmail.com]
> > Sent: Tuesday, September 02, 2014 4:54 PM
> > To: dev@metamodel.incubator.apache.org
> > Subject: Problem executing string-format queries
> >
> > Hi all,
> >
> > I have just come across your awesome library and am integrating it in my
> > project.
> >
> > I have just written a couple of tests and noticed that I can execute a
> > string-format query against a JdbcDataContext whereas I am getting an
> > IllegarArgumentException ( Expression-based filters cannot be manually
> > evaluated) when I execute the same query using a CsvDataContext.
> >
> > This is working fine:
> >
> > val dataContext = DataContextFactory.createJdbcDataContext(connection)
> >         val dataSet = dataContext.executeQuery("""SELECT * FROM
> > public.data_sources WHERE TYPE='rest'""")
> >
> > This is returning the exception:
> >
> >  val dataContext = DataContextFactory.createCsvDataContext(csvFile)
> > WHERE name='rojo'""")
> >
> > Is there any way of executing string queries against all the datacontext
> > types?
> >
> > Thank you!
> >
>

Re: Problem executing string-format queries

Posted by Alberto Rodriguez <ar...@gmail.com>.
Hi Hans,

You are right my code snippet was not complete, here it is:

val dataContext = DataContextFactory.createCsvDataContext(csvFile)
val dataSet = dataContext.executeQuery("""SELECT * FROM testdata.csv WHERE
name='rojo'""")

I have just tested the same with a JsonDataContext and getting the same
exception:

val fileName = "testdata.json"
val jsonFile = new File(s"test/resources/$fileName")
val dataContext = DataContextFactory.createJsonDataContext(jsonFile)
val dataSet = dataContext.executeQuery("""SELECT * FROM testdata.json WHERE
id='1'""")

I am afraid that you can only include 'WHERE' clauses within a executeQuery
method (with a string format query) using the JdbcDataContext.

Kind regards,

Alberto


2014-09-02 16:59 GMT+02:00 Hans Drexler <Ha...@humaninference.com>:

> Hi Alberto,
>
> I am not the biggest expert, but I think queries should work against all
> types of data contexts. That is one leading principle of MetaModel. From
> your code example, it seems the second code snippet (with the csv data
> context) is not complete. There is not a complete query in it. Can you
> double check your code and post? Maybe then we can help better.
>
> Kind regards,
>
> Hans Drexler
>
> -----Original Message-----
> From: Alberto Rodriguez [mailto:ardlema@gmail.com]
> Sent: Tuesday, September 02, 2014 4:54 PM
> To: dev@metamodel.incubator.apache.org
> Subject: Problem executing string-format queries
>
> Hi all,
>
> I have just come across your awesome library and am integrating it in my
> project.
>
> I have just written a couple of tests and noticed that I can execute a
> string-format query against a JdbcDataContext whereas I am getting an
> IllegarArgumentException ( Expression-based filters cannot be manually
> evaluated) when I execute the same query using a CsvDataContext.
>
> This is working fine:
>
> val dataContext = DataContextFactory.createJdbcDataContext(connection)
>         val dataSet = dataContext.executeQuery("""SELECT * FROM
> public.data_sources WHERE TYPE='rest'""")
>
> This is returning the exception:
>
>  val dataContext = DataContextFactory.createCsvDataContext(csvFile)
> WHERE name='rojo'""")
>
> Is there any way of executing string queries against all the datacontext
> types?
>
> Thank you!
>

RE: Problem executing string-format queries

Posted by Hans Drexler <Ha...@HumanInference.com>.
Hi Alberto,

I am not the biggest expert, but I think queries should work against all types of data contexts. That is one leading principle of MetaModel. From your code example, it seems the second code snippet (with the csv data context) is not complete. There is not a complete query in it. Can you  double check your code and post? Maybe then we can help better.

Kind regards,

Hans Drexler

-----Original Message-----
From: Alberto Rodriguez [mailto:ardlema@gmail.com] 
Sent: Tuesday, September 02, 2014 4:54 PM
To: dev@metamodel.incubator.apache.org
Subject: Problem executing string-format queries

Hi all,

I have just come across your awesome library and am integrating it in my project.

I have just written a couple of tests and noticed that I can execute a string-format query against a JdbcDataContext whereas I am getting an IllegarArgumentException ( Expression-based filters cannot be manually
evaluated) when I execute the same query using a CsvDataContext.

This is working fine:

val dataContext = DataContextFactory.createJdbcDataContext(connection)
        val dataSet = dataContext.executeQuery("""SELECT * FROM public.data_sources WHERE TYPE='rest'""")

This is returning the exception:

 val dataContext = DataContextFactory.createCsvDataContext(csvFile)
WHERE name='rojo'""")

Is there any way of executing string queries against all the datacontext types?

Thank you!