How to access the Impala Parser - impala

Does Impala reuse hive SQL parser?
I am trying to write a custom Java code to check for query correctness in my application. I am searching for an api which can consume the sql query and let me know if it is grammatically correct for impala.
How can I access the parser from a custom Java code to check for query compatibility?

No, Impala does not reuse the Hive parser.
Further, Impala does not expose a Java API for checking if a query is grammatically correct.
The easiest thing to do is probably to submit an explain query via JDBC and check the result.
If you don't have a running Impala cluster, in theory you should be able to instantiate the scanner and parser as Impala does in the parser unit tests, but I can imagine it might be difficult to get that working as the Impala build/test environment is quite complicated. Note that this is not a supported API.

Related

Java Sql Generate for Elasticsearch Sql

Is there any java library to build sql queries based on pojos,
Like something similar to hibernate hql queries.
Object sql queries than translated to elastic search sql queries.
Current requirement is to send sql queries through rest apis.
There is jooq library whic can generate for many databases using dialects but currently it doesnt support for EsDriver which is elastic search jdbc driver.
Regards
Rajesh Giriyappa
I find your question a bit confusing. however, I'm gonna mention some facts that might help you.
First of all, elasticsearch is far away from a relational database system. It is a search engine implemented on top of Apache Lucene and stores semi-structured documents in its own data structure called index and it is used for Information Retrieval purposes. having said that, it is impossible to run SQL queries against elasticsearch because obviously it is not an RDBMS.
Furthermore, JPA is targeted only for providing solutions for working with RDBMSs so you can not connect to elasticsearch with JDBC, Hibernate etc.
If you want to connect to elasticsearch in a java application, you should use standard clients provided by elasticsearch itself.
https://www.elastic.co/guide/en/elasticsearch/client/java-rest/7.13/index.html

Use Crate SQL module(plugin) in Elasticsearch

I am using Elasticsearch on linux sever but Quering is a little bit difficult
because form of query is not SQL structure.
In crate, there is a sql plugin, so I put this plugin into my own Elasticsearch
Is it possible?
If not, how can I adopt Crate SQL Plugin into Elasticsearch?
Thanks
Jehyun:
Crate has evolved from being an Elasticsearch plugin to a complete software stack. I don't believe that you can simply add a plugin to Elasticsearch to gain SQL-like queries. You would need to transition your cluster to Crate in order to use SQL queries.
Of course, you should test this process on a non-production system first.

capturing Linq to object queries

Because of performance issue in application we are using in-memory approach for one of my project, in which we are loading all tables in RAM in form of generic collections (using nhibernate).
Issue is that when we were using simple linq to sql approach that time the testing and QA team were easily able to get sql queries using sql profiles for page they were viewing.
but with new approach (in-memory), we are loading all data in collection in one go and then are using linq to get data from that collection, so the testing and QA teams are not able to get the sql queries to verify the business logic and verifying bugs.
Please suggest any solution which can help in this situation, i think its not possible to get sql from linq to object (as all data is already in collection). please suggest any solution/approach/tool which can help me, to generate sql of those linq which is getting run against the collection or any other good solution.
NOTE: i know getting sql out of linq to sql is not possible, i am looking for suggestion which can help my QA and testing team to verify the queries/business logic (like they were doing earlier by capturing sql). like if possible log the linq queries as string which can be further used to be run/analyze.
The only SQL statements that you are running in this situation are the initial SELECT queries to load your data into memory. Once you have done those, you are no longer running "queries", you are instead performing .NET Framework calls.
Given that you have fundamentally changed the architecture of the application, you need to communicate this to the testing and QA teams - they will not be able to "see" what the application is now doing under the hood in the way that they could previously. If this sort of "deep dive" capability is a requirement of your test teams then your architecture is likely to require further modifications.

How to test my Firebird SQL queries

I'm in the process of learning SQL, and I need a way of verifying that my SQL queries are valid (i.e. no syntax errors). I also would like to check what results they yield on a test database of my choosing and structure.
I'm using embedded firebird in my C# .NET application, so I don't really have any tools to work with. Anyone have any tips? Perhaps there are SQL administrators/query IDEs out there that work with Firebird?
You can use IBExpert personal or DatabaseWorkbench Lite
check also this and this

SQLite coalesce problem when running django testcases

I am using django for running my project. And I am using postgresql_psycopg2 engine for my production db, but the test runner uses sqllite3 for running the tests. Keeping my production db(postgresql)in mind I tried building a query which uses "coalesce". But sqllite3 doesn't recognize this. How do I get pass this. I can use postgresql_psycopg2 even for my test running(just to avoid wastage of time), but its too slow. How do I get pass this?
Sqlite does support coalesce but requires at least two arguments. I believe that the Postgresl implementation only requires one parameter while Sqlite requires at least two. Perhaps you are using coalesce with only one parameter in Postgresql and that is breaking when moving to Sqlite?
Could you post the code that is failing?