Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

JSqlParser parses an SQL statement and translate it into a hierarchy of Java classes. The generated hierarchy can be navigated using the Visitor Pattern

License

Apache-2.0, LGPL-2.1 licenses found

Licenses found

Apache-2.0
LICENSE_APACHEV2
LGPL-2.1
LICENSE_LGPLV21
NotificationsYou must be signed in to change notification settings

JSQLParser/JSqlParser

Repository files navigation

CICoverage StatusCodacy BadgeMaven CentralJavadocsGitter

A huge thank you to our sponsor,Starlake.ai who simplifies data ingestion, transformation, and orchestration, enabling faster delivery of high-quality data. Starlake has been instrumental in providing Piped SQL and numerous test cases for BigQuery, Redshift, DataBricks, and DuckDB. Show your support for ongoing development by visiting Starlake.ai and giving us a star!

Summary

Please visit ourWebSite for detailed information.JSqlParser is a RDBMS agnostic SQL statement parser. It translates SQL statements into a traversable hierarchy of Java classes (seeSamples):

SELECT1FROM dualWHERE a= b/* produces the following ASTSQL Text └─Statements: statement.select.PlainSelect    ├─selectItems: statement.select.SelectItem    │  └─LongValue: 1    ├─Table: dual    └─where: expression.operators.relational.EqualsTo       ├─Column: a       └─Column: b*/
StringsqlStr ="select 1 from dual where a=b";PlainSelectselect = (PlainSelect)CCJSqlParserUtil.parse(sqlStr);SelectItemselectItem =select.getSelectItems().get(0);Assertions.assertEquals(newLongValue(1)        ,selectItem.getExpression());Tabletable = (Table)select.getFromItem();Assertions.assertEquals("dual",table.getName());EqualsToequalsTo = (EqualsTo)select.getWhere();Columna = (Column)equalsTo.getLeftExpression();Columnb = (Column)equalsTo.getRightExpression();Assertions.assertEquals("a",a.getColumnName());Assertions.assertEquals("b",b.getColumnName());

Support forPiped SQL

Work is progressing for parsingPiped SQL, a much saner and more logical way to write queries in its semantic order.

FROM Produce|>WHERE    item!='bananas'AND categoryIN ('fruit','nut')|> AGGREGATECOUNT(*)AS num_items,SUM(sales)AS total_salesGROUP BY item|>ORDER BY itemDESC;

For details, please seehttps://storage.googleapis.com/gweb-research2023-media/pubtools/1004848.pdf,https://cloud.google.com/bigquery/docs/reference/standard-sql/pipe-syntax andhttps://duckdb.org/docs/sql/query_syntax/from.html#from-first-syntax

Java Version

JSQLParser-4.9 was the last JDK8 compatible version. JSQLParser-5.0 and later depend on JDK11 and introduce API breaking changes to the AST Visitors. Please see the Migration Guide for the details.

Building JSQLParser-5.1 and newer with Gradle will depend on a JDK17 toolchain due to the used plugins.

JSQLParser-5.4 Snapshot and later use JavaCC-8 Snapshots for generating the parser.

Performance

Unfortunately the released JSQLParser-5.2 shows a performance deterioration caused by commit30cf5d7 related toFunctionAllColumns().This has been resolved in JSQLParser 5.3-SNAPSHOT and JMH benchmarks have been added to avoid such regressions in the future. Further allLOOKAHEAD have been revised one by one, and we have gained back a very good performance of the Parser.

Benchmark                               (version)  Mode  Cnt   Score   Error  UnitsJSQLParserBenchmark.parseSQLStatements     latest  avgt   15  82.695 ± 2.841  ms/opJSQLParserBenchmark.parseSQLStatements        5.3  avgt   15  84.687 ± 3.321  ms/opJSQLParserBenchmark.parseSQLStatements        5.1  avgt   15  86.592 ± 5.781  ms/op

JSqlParser aims to support the SQL standard as well as all major RDBMS. Any missing syntax or features can be added on demand.

RDBMSStatements
Oracle
MS SQL Server and Sybase
Postgres
MySQL and MariaDB
DB2
H2 and HSQLDB and Derby
SQLite
SELECT
INSERT,UPDATE,UPSERT,MERGE
DELETE,TRUNCATE TABLE
CREATE ...,ALTER ....,DROP ...
WITH ...
Salesforce SOQLINCLUDES,EXCLUDES
Piped SQL (also known as FROM SQL)

JSqlParser can also be used to create SQL Statements from Java Code with a fluent API (seeSamples).

Sister Projects

If you like JSqlParser then please check out its related projects:

Alternatives to JSqlParser?

General SQL Parser looks pretty good, with extended SQL syntax (like PL/SQL and T-SQL) and java + .NET APIs. The tool is commercial (license available online), with a free download option.

Alternatively the dual-licensedJOOQ provides a handwritten Parser supporting a lot of RDBMS, translation between dialects, SQL transformation, can be used as a JDBC proxy for translation and transformation purposes.

  1. Samples
  2. Build Instructions andMaven Artifact
  3. Contribution
  4. Change Log
  5. Issues

License

JSqlParser is dual licensed underLGPL V2.1 orApache Software License, Version 2.0.

About

JSqlParser parses an SQL statement and translate it into a hierarchy of Java classes. The generated hierarchy can be navigated using the Visitor Pattern

Topics

Resources

License

Apache-2.0, LGPL-2.1 licenses found

Licenses found

Apache-2.0
LICENSE_APACHEV2
LGPL-2.1
LICENSE_LGPLV21

Stars

Watchers

Forks

Sponsor this project

    Packages

    No packages published

    Languages


    [8]ページ先頭

    ©2009-2025 Movatter.jp