diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 3ece11b..bebc043 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.1.21 +current_version = 0.1.22 commit = True tag = True diff --git a/Cargo.toml b/Cargo.toml index e64abd0..876783f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sqloxide" -version = "0.1.21" +version = "0.1.22" authors = ["Will Eaton "] edition = "2018" @@ -9,12 +9,12 @@ name = "sqloxide" crate-type = ["cdylib"] [dependencies] -pythonize = "0.16" +pythonize = "0.17" [dependencies.pyo3] -version = "0.16" +version = "0.17.1" features = ["extension-module"] [dependencies.sqlparser] -version = "0.21.0" +version = "0.22.0" features = ["json_example"] diff --git a/pyproject.toml b/pyproject.toml index f497204..e713adc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "sqloxide" -version = "0.1.21" +version = "0.1.22" repository = "https://github.com/wseaton/sqloxide" license = "MIT" description = "Python bindings for sqlparser-rs" diff --git a/readme.md b/readme.md index 197237c..0a46848 100644 --- a/readme.md +++ b/readme.md @@ -103,14 +103,14 @@ poetry run pytest tests/benchmark.py ``` ``` -------------------------------------------------------------------------------------------- benchmark: 4 tests ------------------------------------------------------------------------------------------- -Name (time in us) Min Max Mean StdDev Median IQR Outliers OPS Rounds Iterations ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -test_sqloxide 25.8210 (1.0) 45.6700 (1.0) 26.4524 (1.0) 0.8534 (1.0) 26.3000 (1.0) 0.2010 (1.0) 452;600 37,803.7849 (1.0) 8010 1 -test_sqlglot 636.2530 (24.64) 10,335.0290 (226.30) 678.4330 (25.65) 276.6924 (324.21) 653.1080 (24.83) 23.8250 (118.54) 4;225 1,473.9848 (0.04) 1256 1 -test_sqlparser 1,563.2770 (60.54) 1,959.0890 (42.90) 1,630.0581 (61.62) 48.6897 (57.05) 1,612.8780 (61.33) 47.4110 (235.89) 63;21 613.4751 (0.02) 537 1 -test_mozsqlparser 2,707.5730 (104.86) 11,504.0740 (251.90) 3,053.7567 (115.44) 964.2621 (>1000.0) 2,889.7240 (109.88) 243.1393 (>1000.0) 7;10 327.4655 (0.01) 295 1 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +------------------------------------------------------------------------------------------- benchmark: 4 tests ------------------------------------------------------------------------------------------ +Name (time in us) Min Max Mean StdDev Median IQR Outliers OPS Rounds Iterations +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +test_sqloxide 26.6800 (1.0) 58.4100 (1.0) 27.5952 (1.0) 2.3653 (1.0) 27.2300 (1.0) 0.3001 (1.0) 121;310 36,238.2428 (1.0) 4622 1 +test_sqlglot 646.0550 (24.21) 932.9370 (15.97) 668.1087 (24.21) 26.1988 (11.08) 659.3050 (24.21) 8.2647 (27.54) 171;184 1,496.7624 (0.04) 1355 1 +test_sqlparser 1,551.8610 (58.17) 2,255.7170 (38.62) 1,625.3044 (58.90) 74.4809 (31.49) 1,605.4370 (58.96) 38.4900 (128.27) 29;33 615.2694 (0.02) 542 1 +test_mozsqlparser 2,798.2310 (104.88) 9,845.7520 (168.56) 3,051.8365 (110.59) 745.5932 (315.22) 2,932.6010 (107.70) 237.6895 (792.14) 4;4 327.6715 (0.01) 293 1 +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ``` ## Example diff --git a/setup.py b/setup.py index 276160d..5601d1b 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ setup_kwargs = { 'name': 'sqloxide', - 'version': '0.1.21', + 'version': '0.1.22', 'description': 'Python bindings for sqlparser-rs', 'long_description': open('readme.md').read(), 'long_description_content_type': 'text/markdown', diff --git a/src/lib.rs b/src/lib.rs index c8cea94..a450efd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,16 +9,17 @@ use sqlparser::parser::Parser; fn string_to_dialect(dialect: &str) -> Box { match dialect.to_lowercase().as_str() { - "generic" => Box::new(GenericDialect {}), "ansi" => Box::new(AnsiDialect {}), + "bigquery" | "bq" => Box::new(BigQueryDialect {}), + "clickhouse" => Box::new(ClickHouseDialect {}), + "generic" => Box::new(GenericDialect {}), "hive" => Box::new(HiveDialect {}), "ms" | "mssql" => Box::new(MsSqlDialect {}), "mysql" => Box::new(MySqlDialect {}), "postgres" => Box::new(PostgreSqlDialect {}), + "redshift" => Box::new(RedshiftSqlDialect {}), "snowflake" => Box::new(SnowflakeDialect {}), "sqlite" => Box::new(SQLiteDialect {}), - "clickhouse" => Box::new(ClickHouseDialect {}), - "redshift" => Box::new(RedshiftSqlDialect {}), _ => { println!("The dialect you chose was not recognized, falling back to 'generic'"); Box::new(GenericDialect {}) @@ -28,8 +29,8 @@ fn string_to_dialect(dialect: &str) -> Box { /// Function to parse SQL statements from a string. Returns a list with /// one item per query statement. -/// -/// Available `dialects`: +/// +/// Available `dialects`: /// - generic /// - ansi /// - hive @@ -40,7 +41,8 @@ fn string_to_dialect(dialect: &str) -> Box { /// - sqlite /// - clickhouse /// - redshift -/// +/// - bigquery (bq) +/// #[pyfunction] #[pyo3(text_signature = "(sql, dialect)")] fn parse_sql(py: Python, sql: &str, dialect: &str) -> PyResult { @@ -53,7 +55,10 @@ fn parse_sql(py: Python, sql: &str, dialect: &str) -> PyResult { } Err(_e) => { let msg = _e.to_string(); - return Err(PyValueError::new_err(format!("Query parsing failed.\n\t{}", msg))); + return Err(PyValueError::new_err(format!( + "Query parsing failed.\n\t{}", + msg + ))); } }; diff --git a/tests/benchmark.py b/tests/benchmark.py index fc8158c..3dcac8d 100644 --- a/tests/benchmark.py +++ b/tests/benchmark.py @@ -39,8 +39,10 @@ def test_sqloxide(benchmark): def test_sqlparser(benchmark): benchmark(bench_sqlparser) + def test_mozsqlparser(benchmark): benchmark(bench_mozsqlparser) + def test_sqlglot(benchmark): benchmark(bench_sqlglot)