Questions relating to code, libraries, or applications that parse SQL-style query languages.
Questions tagged [sql-parser]
129 questions
1
vote
0 answers
SQL WHERE Clause Parser by boost qi
I want to implement some rules of SQL WHERE clause parser by boost qi. If ound the its BNF on https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#_8_4_in_predicate. I implemented a specific predicate rules by some special…

Mehdi Karimi
- 11
- 1
1
vote
0 answers
Is there a PostgreSQL SQL query string parser for PHP?
I need to turn PostgreSQL query strings in my application, such as:
$db_query_string = '
SELECT *
FROM "the schema"."a table" -- This is an SQL comment. At least in PostgreSQL.
WHERE blabla = 123
AND "another column" = $1
…

Makar Silveus
- 11
- 1
1
vote
0 answers
Parsing an SQL statement to isolate the formulas being used to create the columns after a SELECT statement
I am trying to parse an SQL statement, the output of which should provide me the formulas to create the columns using attributes from the table that is being ingested using the FROM clause.
Eg.
SELECT col1 AS a, SUM((col2/t2.col7 - col9)) AS b, col3…

Vivek Kumar
- 11
- 1
1
vote
1 answer
How to parse standard SQL (BigQuery) to get input columns and output columns
We're building a data warehouse in BigQuery where we generate a large amount of data marts using standard sql statements. These can be quite large and complex. To track data lineage across a chain of dependencies, we'd like to automatically parse…

Bjoern
- 433
- 3
- 16
1
vote
0 answers
How can one use moz_sql_parser and DeepDiff to compare two sql Querys?
I am using moz_sql_parser to compare two SQL querys. And DeepDiff to see the diferences between the two querys.
I want a diferent kind of dictionary as showed below to perform better comparissons.
from moz_sql_parser import parse
import json
from…

Joao Gracio
- 11
- 4
1
vote
1 answer
Calcite parse sql into parts for mult data source
In my case I'm querying data from multi data source(like csv+mysql) via a single sql. How can I distinguish the data source for tables and detect what columns are queried on tables by using Calcite? (Meta data of data source available)
Result that I…

iterrole
- 13
- 3
1
vote
0 answers
Plpython UDF using PostgreSQL
I have a created a function that utilizes the sqlparse module to extract all of the tables hit from any given sql statement:
create or replace function my_function(x text) returns text
as $$
import sqlparse
from collections import namedtuple
from…

SQLNOOB
- 13
- 3
1
vote
1 answer
how to get table name with join operation
I want to get table name from 'FROM' and 'JOIN'. This is the example of the query:
SELECT * FROM film JOIN language ON film.language_id = language.language_id WHERE language_name = "English"
I use sqlparse library in python. This is I've…

wdwilhelmina
- 39
- 1
- 7
1
vote
1 answer
Is it possible to configure Apache Calcite identifiers to be case insensitive?
The Calcite SQL language reference (https://calcite.apache.org/docs/reference.html) says the following:
In Calcite, matching identifiers to the name of the referenced object is case-sensitive. But remember that unquoted identifiers are implicitly…

tuzhucheng
- 158
- 3
- 9
1
vote
3 answers
Get table name from SQL query
I am using golang SQL parser to fetch query related information from actual SQL query string. I am able to find the type of query using following code:
queryType := sqlparser.StmtType(sqlparser.Preview(sql))
fmt.Println(queryType)
but i am not sure…

Hassnain Alvi
- 87
- 2
- 12
1
vote
0 answers
Unable to find dependency 'MICROSOFT.SQLSERVER.MANAGEMENT.SQLPARSER'
I am trying to deploy a winforms app and it won't start when I run the Setup file. I have checked the log during the build of the setup project and it says that I need version 11 of:
MICROSOFT.SQLSERVER.MANAGEMENT.SQLPARSER
I am currently running…

The OrangeGoblin
- 764
- 2
- 7
- 27
1
vote
1 answer
Get table name from string query irrespective of CRUD operation
I have string like below. I have to get all table name from this.
select SEQ_NO,CODE,CD_NAME,CD_TYPE,CD_CITY,CDS_STATUS,CDS_SUBSTATUS,
to_char(CDS_LAST_MOD_DATE,'dd/mm/yyyy') as CDS_LAST_MOD_DATE from
company_details left outer join on…

Nivetha Elangovan
- 83
- 1
- 1
- 8
1
vote
0 answers
legacy oracle sql syntax convert python
I am converting legacy oracle sql join syntax to ANSI sql code compatible in postgres . I am using python to create utility for this purpose . So far so good from my research I have found to use sqlparser python library .
Sample sql syntax :
…

pikas
- 83
- 7
1
vote
1 answer
Error on parsing T-SQL using TSql120Parser
Hello stackoverflowers,
I've got a problem parsing T-SQL statements using TSql120Parser from Microsoft.SqlServer.TransactSql.ScriptDom. My goal is to simply parse a T-SQL select statement and get it's tokens.
This is the essential part of the…

S. Spindler
- 546
- 3
- 12
1
vote
2 answers
Can we execute SQL without having a real database connection in java?
Can we execute SQL without having a real database connection in java?
example:
SELECT CASE
WHEN :param = 1 THEN 'TEST1'
WHEN :param = 2 THEN 'TEST2'
WHEN :param = 3 THEN 'TEST3'
END
AS RESULT
FROM…

user1097437
- 111
- 3
- 12