Skip to content

Commit

Permalink
Updates (#183)
Browse files Browse the repository at this point in the history
* add bq dialect

* bump versions, update benchmarks

* [ci] upgrade poetry's install script

* Revert "[ci] upgrade poetry's install script"

This reverts commit bc43d6f.
  • Loading branch information
wseaton committed Sep 2, 2022
1 parent 88dfd30 commit 4fe55d6
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.1.21
current_version = 0.1.22
commit = True
tag = True

Expand Down
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sqloxide"
version = "0.1.21"
version = "0.1.22"
authors = ["Will Eaton <me@wseaton.com>"]
edition = "2018"

Expand All @@ -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"]
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
16 changes: 8 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
19 changes: 12 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ use sqlparser::parser::Parser;

fn string_to_dialect(dialect: &str) -> Box<dyn Dialect> {
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 {})
Expand All @@ -28,8 +29,8 @@ fn string_to_dialect(dialect: &str) -> Box<dyn Dialect> {

/// Function to parse SQL statements from a string. Returns a list with
/// one item per query statement.
///
/// Available `dialects`:
///
/// Available `dialects`:
/// - generic
/// - ansi
/// - hive
Expand All @@ -40,7 +41,8 @@ fn string_to_dialect(dialect: &str) -> Box<dyn Dialect> {
/// - sqlite
/// - clickhouse
/// - redshift
///
/// - bigquery (bq)
///
#[pyfunction]
#[pyo3(text_signature = "(sql, dialect)")]
fn parse_sql(py: Python, sql: &str, dialect: &str) -> PyResult<PyObject> {
Expand All @@ -53,7 +55,10 @@ fn parse_sql(py: Python, sql: &str, dialect: &str) -> PyResult<PyObject> {
}
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
)));
}
};

Expand Down
2 changes: 2 additions & 0 deletions tests/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 4fe55d6

Please sign in to comment.