Commit Graph

266 Commits

Author SHA1 Message Date
Thomas Desrosiers
03b2b06e90 fix: Update time grain expressions for Spark >= 3.x (#18690)
* Fix the time grain expressions for Spark >= 2.3.0

Spark removed date format string 'u' in Spark 3.0. Switch to using date_trunc which has been around since 2.3

* Review: Pull out time_grain_expressoins into its own thing
2022-03-08 13:21:13 -08:00
saurabh gulati
d632590eff stop query on the processing engine when user clicks STOP on SQL Lab (#18789)
Co-authored-by: Saurabh Gulati <saurabh.gulati@fedex.com>
2022-02-22 09:19:34 +02:00
Sujith Kumar S
7e51b200b4 fix(mssql): support top syntax for limiting queries (#18746)
* SQL-TOP Fix For Database Engines

MSSQL is not supporting LIMIT syntax in SQLs. For limiting the rows, MSSQL having a different keyword TOP. Added fixes for handling the TOP and LIMIT clauses based on the database engines.

* Teradata code for top clause handling removed from teradata.py

Teradata code for top clause handling removed from teradata.py file, since we added generic section in base engine for the same.

* Changes to handle CTE along with TOP in complex SQLs

Added changes to handle TOP command in CTEs, for DB Engines which are not supporting inline CTEs.

* Test cases for TOP unit testing in MSSQL

Added multiple unit test cases for MSSQL top command handling and also along with CTEs

* Corrected the select_keywords name key in basengine

Corrected the select_keywords name key in basengine

* Changes based on as per review.

made the required corrections based on code review to keep good code readability and code cleanliness.

* Review changes to correct lint and typo issues

Made the changes according to the review comments.

* fix linting errors

* fix teradata tests

* add coverage

* lint

* Code cleanliness

Moved the top/limit flag check from sql_lab to core.

* Changed for code cleanliness

Changes for keeping code cleanliness

* Corrected lint issue

Corrected lint issue.

* Code cleanliness

Code cleanliness

Co-authored-by: Ville Brofeldt <ville.v.brofeldt@gmail.com>
2022-02-21 09:58:39 +02:00
Beto Dealmeida
40ab26d4f1 fix: unambiguous trino driver (#18683) 2022-02-11 17:40:20 -08:00
Sujith Kumar S
b8aef10098 fix(mssql): support cte in virtual tables (#18567)
* Fix for handling regular CTE queries with MSSQL,#8074

* Moved the get_cte_query function from mssql.py to base.py for using irrespetcive of dbengine

* Fix for handling regular CTE queries with MSSQL,#8074

* Moved the get_cte_query function from mssql.py to base.py for using irrespetcive of dbengine

* Unit test added for the db engine CTE SQL parsing.

Unit test added for the db engine CTE SQL parsing.  Removed additional spaces from the CTE parsing SQL generation.

* implement in sqla model

* lint + cleanup

Co-authored-by: Ville Brofeldt <ville.v.brofeldt@gmail.com>
2022-02-10 10:28:05 +02:00
Dave McNulla
8c376548e3 fix(teradata): LIMIT syntax (#18240)
Co-authored-by: Mccush, Jack <jack.mccush@teradata.com>
Co-authored-by: Jack McCush <33156805+mccushjack@users.noreply.github.com>
Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>
Co-authored-by: David McNulla <david.mcnulla@teradata.com>
2022-01-31 19:15:42 -08:00
Đặng Minh Dũng
0b67fe1beb feat: Trino Authentications (#17593)
* feat: support Trino Authentications

Signed-off-by: Đặng Minh Dũng <dungdm93@live.com>

* docs: Trino Authentications

Signed-off-by: Đặng Minh Dũng <dungdm93@live.com>
2022-01-14 21:02:47 -08:00
Đặng Minh Dũng
5a740901d6 cleanup column_type_mappings (#17569)
Signed-off-by: Đặng Minh Dũng <dungdm93@live.com>
2022-01-14 11:07:17 +02:00
Mikhail Kumachev
d2d4f8eb44 feat: Add support for Azure Data Explorer (Kusto) db engine spec (#17898)
* Add two Kusto engine specs: KQL and SQL. Some minor changes in core code to support Kusto engine specs.

* Remove redundant imports and logging.

* docs: Kusto sqlalchemy docs

* fix: Fix mypy and linting errors

* fix: Handle Black vs Pylint checks

* fix: isort problem

* refactor: Merge kustosql and kustokql in the single kusto module

* test: Add tests for Kusto db spec

* feat: Schema override does not require in KQL anymore

* Removed redundant imports.

* Added ".show" queries to readonly query determination.

* Fixed some bugs.
Added tests for convert_dttm.

* Fixed major sqlalchemy-kusto version.

* Fixed by isort.

Co-authored-by: Eugene Bikkinin <xnegxneg@gmail.com>
Co-authored-by: k.tomak <k.tomak@dodopizza.com>
Co-authored-by: Eugene Bikkinin <e.bikkinin@dodopizza.com>
2022-01-10 14:42:20 +02:00
Ville Brofeldt
6a7e6490a9 fix(postgres): remove redundant tz factory (#17713)
* fix(postgres): remove redundant tz factory

* lint
2021-12-10 21:53:48 +02:00
Ville Brofeldt
1af99eabc2 chore: unblock ci on postgres lint (#17705) 2021-12-09 16:12:46 +02:00
Ville Brofeldt
b2ffa268cd fix(sqla): make text clause escaping optional (#17641) 2021-12-03 12:35:26 +02:00
PApostol
ce92fc152b Update docstrings in presto.py (#17623) 2021-12-02 08:35:25 +02:00
Đặng Minh Dũng
ebb34196f2 feat: trino support server-cert (#16346)
Signed-off-by: Đặng Minh Dũng <dungdm93@live.com>
2021-11-26 13:28:15 +02:00
aniaan
5a1c68177e fix(elasticsearch): time_zone setting does not work for cast datetime expressions (#17048)
* fix(elasticsearch): cast does not take effect for time zone settings

* test(elasticsearch): add test

* fix(test): fix typo

* docs(elasticsearch): add annotation

* docs(elasticsearch): add time_zone desc

* docs(elasticsearch): fix typo

* refactor(db_engine): change convert_dttm signature

* fix(test): fix test

* fix(es): add try catch

* fix(test): fix caplog

* fix(test): fix typo
2021-11-25 11:58:44 +02:00
Long Le Xich
bc855f4040 fix(hive): Update _latest_partition_from_df in HiveEngineSpec to work on tables with multiple indexes (#14302)
* Fix _latest_partition_from_df in HiveEngineSpec

* Add test HiveEngineSpec._latest_partition_from_df

* Fix formatting to pass black

Co-authored-by: Ville Brofeldt <ville.v.brofeldt@gmail.com>
2021-11-23 10:07:47 +02:00
Rafał Ganczarek
8da982bc7c fix(presto): expand data with null item (#17470)
* fix(presto): expand data with null item

* Fixed pre-commit check
2021-11-21 20:10:35 +02:00
binome74
211b32a4cd fix(mssql): week time grain should respect datefirst setting (#10811)
* "P1W" grain should respect DATEFIRST setting in MS SQL Server

* Added "week_start_sunday" and "week_start_monday" grains support. Adjusted the "week" grain for better backward compatibility with MS SQL 2005/2008.

* Stylistic and linter-requested changes

* fix test

Co-authored-by: Valeriy Aleksashkin <v.aleksashkin@gmail.com>
Co-authored-by: Ville Brofeldt <ville.v.brofeldt@gmail.com>
2021-11-16 09:36:37 +02:00
minzhang2110
9741eaa731 Fix 'DataFrame' object has no attribute 'ix' (#12092)
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python3.7/site-packages/flask_appbuilder/security/decorators.py", line 109, in wraps
    return f(self, *args, **kwargs)
  File "/app/superset/utils/log.py", line 164, in wrapper
    value = f(*args, **kwargs)
  File "/app/superset/views/core.py", line 2037, in extra_table_metadata
    mydb, table_name, parsed_schema
  File "/app/superset/db_engine_specs/presto.py", line 734, in extra_table_metadata
    table_name, schema_name, database, show_first=True
  File "/usr/local/lib/python3.7/site-packages/flask_caching/__init__.py", line 907, in decorated_function
    rv = f(*args, **kwargs)
  File "/app/superset/db_engine_specs/presto.py", line 977, in latest_partition
    return column_names, cls._latest_partition_from_df(df)
  File "/app/superset/db_engine_specs/hive.py", line 435, in _latest_partition_from_df
    return [df.ix[:, 0].max().split("=")[1]]
  File "/usr/local/lib/python3.7/site-packages/pandas/core/generic.py", line 5139, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'DataFrame' object has no attribute 'ix'

Co-authored-by: Ville Brofeldt <ville.v.brofeldt@gmail.com>
2021-11-15 16:52:50 +02:00
CodeingBoy
2544a4a8ac fix(sqllab): Bugfix for tracking url transformation (#17263)
* Bugfix for tracking url transformation

* Fix linting
2021-11-11 11:16:55 +02:00
Christian Pfarr
333b1371f7 feat: Drill ODBC/JDBC Impersonation feature (#17353)
* Added Drill ODBC Impersonation feature and necessary translations/docs

* Code Cleanup

* add jdbc impersonation_target parameter

* add unittests for DrillEngineSpec.modify_url_for_impersonation method

* reformat test_drill.py with black formatter

* run pre-commit locally

Co-authored-by: Christian Pfarr <Christian.Pfarr@deutschebahn.com>
Co-authored-by: Christian Pfarr <z0ltrix+gitlab@pm.me>
2021-11-10 08:45:16 +02:00
Craig Rueda
6a63a21e06 chore: Bumping pyarrow / pandas (#17290)
* Bumping pyarrow / pandas

* Appeasing the pylint gods

* Adjusting UPDATING.md

* Buping testing requirements
2021-10-31 10:47:02 -07:00
Yongjie Zhao
bedb8f4dff fix(bigquery): calculated column cannot orderby in BigQuery (#17196)
* fix(bigquery): calculated column cannot orderby in BigQuery

* typo

* add ut

* fix lint
2021-10-22 22:42:58 +08:00
John Bodley
d38e686e63 Update druid.py (#17146) 2021-10-18 15:04:56 -07:00
John Bodley
565ee2318d chore(druid): Explicitly cast col to TIMESTAMP (#17101)
Co-authored-by: John Bodley <john.bodley@airbnb.com>
2021-10-18 10:06:04 -07:00
Hugh A. Miles II
40b88f04f6 feat: DBC UI Snowflake Form (#16856)
* update snowflake spec for dyanmic form

* feat(snowflake): Snowflake dynamic form (#16861)

* snowflake frontend

* snowflake frontend

* refactor(DB Connections): Build Snowflake Dynamic Form (#16875)

* moved all non-BasicParameters into own field

* refactored DB Connection Form made ValidatedInput

* quick fix

* fixed ValidatedInputField (#16934)

* add logic to check for required fields (#17022)

* fix

* fix linting

* remove host

* Update EncryptedField.tsx

Co-authored-by: AAfghahi <48933336+AAfghahi@users.noreply.github.com>
2021-10-16 20:46:06 -04:00
John Bodley
b9ff85d9ea chore(engine): Translate fractional time grains—requires @superset-ui bump (#17078)
* chore(engine): Translate fractional time grains

* Bump @superset-ui

Co-authored-by: John Bodley <john.bodley@airbnb.com>
2021-10-12 21:40:48 -07:00
John Bodley
11d52cb4e1 Update druid.py (#17079) 2021-10-12 15:14:40 -07:00
John Bodley
5e85f48515 chore(druid): Standardizing time grain transformations (#17050)
* chore(druid): Standardizing time grain transformations

* Update druid_tests.py

* Update druid_tests.py

Co-authored-by: John Bodley <john.bodley@airbnb.com>
2021-10-12 08:34:28 -07:00
AAfghahi
e32a12fa0b bug fix (#17019) 2021-10-08 10:19:04 -07:00
Beto Dealmeida
c993c5845f fix(BigQuery): explicitly quote columns in select_star (#16822)
* fix (BigQuery): explicitly quote columns in select_star

* Fix test

* Fix SELECT * in BQ

* Add unit tests

* Remove type changes
2021-10-06 07:43:32 -07:00
apurva-sigmoid
420eff42b8 feat: add Firebolt DB engine spec (#16903)
* New branch from superset for integration with firebolt sqlalchemy adapter

* Added db_engine_spec file for Firebolt

* Removed firebolt code from superset repo

* Deleted virtual env commit

* Adding time grain changes to firebolt.py

* Updated README.md

Added steps to install and run Superset with Firebolt SQLAlchemy Adapter

* Update README.md

Reduced installation steps. Using PyPi installation for adapter now

* Revert "Update README.md"

This reverts commit 5ed17c7a45.

* Revert "Updated README.md"

This reverts commit 45c5072649.

* added epoch methods, added test cases for firebolt db engine spec and edited setup.py

* Added license to files

* Added documentation for Firebolt-SQLAlchemy

* Removed trailing whitespace

Co-authored-by: raghavsharma <raghavs@sigmoidanalytics.com>
Co-authored-by: raghavSharmaSigmoid <88667094+raghavSharmaSigmoid@users.noreply.github.com>
2021-10-01 19:43:15 +03:00
Beto Dealmeida
0ea83c5a00 feat: add Databricks ODBC engine spec (#16862)
* feat: add Databricks ODBC engine spec

* Rename Databricks specs
2021-09-28 19:36:28 -07:00
AAfghahi
aa747219ad feat: Add Private Google Sheets to dynamic form (#16628)
* first pass private gsheets

* made encrypted extra into string, refactored onParametersChanged

* private sheets working, credential_info errors

* all but test connection working

* first pass private gsheets

* made encrypted extra into string, refactored onParametersChanged

* private sheets working, credential_info errors

* all but test connection working

* Regenerate package-lock.json

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>
2021-09-28 17:08:50 -07:00
ofekisr
c520eb79b0 refactor: sqllab: move sqllab ralated enumns and utils to more logical place (#16843)
* refactor move QueryStatus to common

* refactor move apply_display_max_row_limit to sqllab package

* refactor move limiting_factor to sqllab package

* fix pylint issues
2021-09-26 21:15:57 +03:00
Ke Zhu
0d064f4451 Be able to lookup driver by engine alias (#16800) 2021-09-24 12:31:17 +03:00
Beto Dealmeida
76f0408932 feat: handle temporal columns in group bys (#16795)
* feat: handle temporal columns in group bys

* Rebase
2021-09-23 15:18:17 -07:00
Beto Dealmeida
5cb49d2de0 feat: add support for JOIN in Druid (#16770) 2021-09-22 10:06:01 -07:00
Ville Brofeldt
836b5e2c86 feat: add support for generic series limit (#16660)
* feat: add support for generic series limit

* refine series_columns logic

* update docs

* bump superset-ui

* add note to UPDATING.md

* remove default value for timeseries_limit
2021-09-16 12:09:08 +03:00
Yongjie Zhao
21f98ddc21 fix: catch exception when create connection (#16692)
* fix: catch exception when create connection

* fix lint

* added UT
2021-09-16 15:55:57 +08:00
John Bodley
fb4650a6eb chore(pylint): Remove top-level disable (#16589)
* chore(pylint): Remove top-level disable

* Update examples.py

* Update command.py

Co-authored-by: John Bodley <john.bodley@airbnb.com>
2021-09-15 09:30:23 -07:00
John Bodley
1669947bcd chore(pylint): Reenable too-many-lines check (#16287)
Co-authored-by: John Bodley <john.bodley@airbnb.com>
2021-09-13 13:22:19 -07:00
Ville Brofeldt
6465ee7dbd fix(sqla): support for date adhoc filter (#16634) 2021-09-09 06:41:50 +03:00
Ville Brofeldt
9de2196b7f fix: TemporalWrapperType string representation (#16614)
* fix: TemporalWrapperType string representation

* fix tests
2021-09-07 13:50:24 +03:00
Beto Dealmeida
359383b578 feat: Add Aurora Data API engine spec (#16535)
* feat: Add Aurora Data API engine spec

* Fix lint
2021-09-04 08:40:14 -07:00
Eugene Klimov
1badcaed45 feat: add function list to auto-complete to Clickhouse datasource (#16234)
* add function list to auto-complete to Clickhouse datasource, fix https://github.com/apache/superset/issues/15477

Signed-off-by: Slach <bloodjazman@gmail.com>

* add function list to auto-complete to Clickhouse datasource, fix https://github.com/apache/superset/issues/15477
fix review comments https://github.com/apache/superset/pull/16234#discussion_r688362980

Signed-off-by: Slach <bloodjazman@gmail.com>

* fix CI/CD https://github.com/apache/superset/pull/16234/checks?check_run_id=3396235776 and https://github.com/apache/superset/pull/16234/checks?check_run_id=3396235707

Signed-off-by: Slach <bloodjazman@gmail.com>

* fix black formatting

Signed-off-by: Slach <bloodjazman@gmail.com>

* fix isort pre-commit hook

Signed-off-by: Slach <bloodjazman@gmail.com>
2021-08-26 18:55:43 +08:00
Beto Dealmeida
5e472980a6 feat: add Shillelagh DB engine spec (#16416) 2021-08-24 17:07:29 -07:00
John Bodley
7e4c940314 chore(pylint): Enable useless-suppression check (#16388)
Co-authored-by: John Bodley <john.bodley@airbnb.com>
2021-08-24 03:58:41 +12:00
Srini Kadamati
5f060a2227 feat: Adding Rockset db engine spec (#16167)
* rockset prototype

* rockset

* t

* removed print / logging

* set a more specific version range for Rockset library
2021-08-18 13:04:59 +03:00
Beto Dealmeida
8a36356f49 fix: rename Databricks (#16297) 2021-08-17 11:16:51 -07:00