Questions relating to code, libraries, or applications that parse SQL-style query languages.
Questions tagged [sql-parser]
129 questions
0
votes
2 answers
How to get a parameter to the ANTLR lexer object?
I'm writing a JAVA software to parse SQL queries. In order to do so I'm using ANTLR with presto.g4.
The code I'm currently using is pretty standard:
PrestoLexer lexer = new PrestoLexer(
new…

Nir99
- 185
- 3
- 15
0
votes
1 answer
SQL Parser Visitor + Metabase + Presto
I'm facing what seems to be a quite easy problem, but I'm not able to put my head around the problem to find a suitable solution.
Problem:
I need to append the schema into my SQL statement, in a "weird"(with schema in double quotes) way.
FROM…

Geny Herrera
- 66
- 4
0
votes
1 answer
Generate SQL statement using Facebook Presto SQL Parser
I am struggling to generate the SQL statement using the Presto Parser. Here are the usecase details-
Parse existing SQL statement which is generated using external
frontend ui (nodejs app).
Append new columns and where clause conditions.
Regenerate…

Rahul Sharma
- 5,614
- 10
- 57
- 91
0
votes
2 answers
what is the better way read a Block of SQL statements from a file using Shell Script?
I am having a file like below , which has many SQL statements. I want to read a particular block of SQL whenever needed.
MyFile.SQL
#QUERY1
SET ECHO OFF NEWP 0 SPA 0 PAGES 0 FEED OFF HEAD OFF TRIMS ON TAB OFF
SET VERIFY OFF
SET NUMFORMAT…

1stenjoydmoment
- 229
- 3
- 14
0
votes
1 answer
how to traverse sqlNode in calcite
I need to convert all the table name and column name to another name in a SQL query which will be in form of string and I have to do it using the Calcite SQL parser. I only know that I have to implement the visitor interface, but I have no clue how…

Jay dev
- 17
- 7
0
votes
2 answers
Get fields used within SQL query
I would like to be able to return a list of all fields (ideally with the table details) used by an given SQL query. E.g. the input of the query:
SELECT t1.field1, field3
FROM dbo.table1 AS t1
INNER JOIN dbo.table2 as t2
ON t2.field2 =…

J.Warren
- 728
- 1
- 4
- 14
0
votes
0 answers
Parsing SQL embedded in codebase
I'm working with a codebase that has a lot of embedded SQL queries in strings and separate code files which makes it difficult to document data requirements for the application. There are some basic tools like sqlparse in python and rather advanced…

John Drinane
- 1,279
- 2
- 14
- 25
0
votes
0 answers
Error while updating mongodatabase collections from django app using djongo
I am facing an error. I am trying out the polls tutorial as provided in the django documentation. The problem is with the django 'F' function. I am trying to update the number of votes for a choice. If I load the choice object into python memory and…

Debdipta Halder
- 497
- 1
- 5
- 19
0
votes
3 answers
How to use JSQL Parser to retrieve table names from a query?
I started to write code to parse a SQL query only to find out that there are APIs available for the same. When I saw JSQLParser here, downloaded the jar using the given dependency
com.github.jsqlparser
…

Metadata
- 2,127
- 9
- 56
- 127
0
votes
0 answers
Why does Microsoft.SqlServer.TransactSql.ScriptDom.TSqlParser fail to parse a simple valid expression?
We are using Microsoft.SqlServer.TransactSql.ScriptDom heavily to process some SQL scripts.
Our understanding is that the parser is supposed to be full fidelity.
However, we recently found this bug:
using…

Clement
- 3,990
- 4
- 43
- 44
0
votes
1 answer
How to parse multiple sql statements with Calcite
I want to know how to parse multiple statements in one string.
sqlparser.parseStmt() can only parse one statement.
For example, I have one string:
Create Table tbl1(id bigint); Select * from tbl1;
How to split the string to two SQL statements.
I…
0
votes
0 answers
How to use SQL-parser in node js?
I am using node+ejs for rendering the pages. In one page I want to validate the SQL query syntax which is been entered. By searching I got to know sql-parser is the way to do that but I don't know how to do.
Now my question is, how to use…

Wolverine
- 17
- 7
0
votes
2 answers
Converting SQL Query with Aggregate Function to Relational Algebra Expression in Apache Calcite - No match found for function signature
I'm trying to convert a SQL query to a relational algebra expression using the Apache Calcite SqlToRelConverter.
It works fine for this query (quotes are for ensuring lowercase):
queryToRelationalAlgebraRoot("SELECT \"country\" FROM…

tuzhucheng
- 158
- 3
- 9
0
votes
2 answers
Parse CASE WHEN statements with sqlparse
I have the following SQL query and would like to parse it using sqlparse
import sqlparse
query = """
select SUM(case when(A.dt_unix<=86400
and B.flag="V") then 1
end) as TEST_COLUMN_1,
SUM(case when(A.Amt -…

Giorgos Myrianthous
- 36,235
- 20
- 134
- 156
0
votes
2 answers
Do SQL parsers just interpret IN as a series of OR conditions?
When writing an SQL query such as
SELECT ID, NAME FROM USER_TABLE WHERE ID IN (1, 2, 10, 14, 15, ..., n)
does the parser just rephrase that into this?
SELECT ID, NAME FROM USER_TABLE WHERE ID = 1
OR ID = 2
…

SandPiper
- 2,816
- 5
- 30
- 52