mirror of
https://github.com/getredash/redash.git
synced 2025-12-19 17:37:19 -05:00
add e6data query runner with test cases (#6604)
* add e6data query runner with test cases * added more test cases
This commit is contained in:
BIN
client/app/assets/images/db-logos/e6data.png
Normal file
BIN
client/app/assets/images/db-logos/e6data.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.2 KiB |
125
poetry.lock
generated
125
poetry.lock
generated
@@ -1,4 +1,4 @@
|
||||
# This file is automatically @generated by Poetry 1.7.0 and should not be changed by hand.
|
||||
# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand.
|
||||
|
||||
[[package]]
|
||||
name = "adal"
|
||||
@@ -1050,6 +1050,26 @@ idna = ["idna (>=2.1,<4.0)"]
|
||||
trio = ["trio (>=0.14,<0.23)"]
|
||||
wmi = ["wmi (>=1.5.1,<2.0.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "e6data-python-connector"
|
||||
version = "1.1.9"
|
||||
description = "Client for the e6data distributed SQL Engine."
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
files = [
|
||||
{file = "e6data-python-connector-1.1.9.tar.gz", hash = "sha256:b8b3ea750b397ddc7aa250c46ed8b2ae00edab64267ffce9a76e4add69d79fe8"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
future = "*"
|
||||
grpcio = "*"
|
||||
grpcio-tools = "*"
|
||||
pycryptodome = "*"
|
||||
python-dateutil = "*"
|
||||
pytz = "*"
|
||||
sqlalchemy = ">=1.0.0"
|
||||
thrift = "*"
|
||||
|
||||
[[package]]
|
||||
name = "elementpath"
|
||||
version = "4.1.5"
|
||||
@@ -1624,6 +1644,66 @@ files = [
|
||||
[package.extras]
|
||||
protobuf = ["grpcio-tools (>=1.59.2)"]
|
||||
|
||||
[[package]]
|
||||
name = "grpcio-tools"
|
||||
version = "1.48.2"
|
||||
description = "Protobuf code generator for gRPC"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
files = [
|
||||
{file = "grpcio-tools-1.48.2.tar.gz", hash = "sha256:8902a035708555cddbd61b5467cea127484362decc52de03f061a1a520fe90cd"},
|
||||
{file = "grpcio_tools-1.48.2-cp310-cp310-linux_armv7l.whl", hash = "sha256:92acc3e10ba2b0dcb90a88ae9fe1cc0ffba6868545207e4ff20ca95284f8e3c9"},
|
||||
{file = "grpcio_tools-1.48.2-cp310-cp310-macosx_10_10_x86_64.whl", hash = "sha256:e5bb396d63495667d4df42e506eed9d74fc9a51c99c173c04395fe7604c848f1"},
|
||||
{file = "grpcio_tools-1.48.2-cp310-cp310-manylinux_2_17_aarch64.whl", hash = "sha256:84a84d601a238572d049d3108e04fe4c206536e81076d56e623bd525a1b38def"},
|
||||
{file = "grpcio_tools-1.48.2-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:70564521e86a0de35ea9ac6daecff10cb46860aec469af65869974807ce8e98b"},
|
||||
{file = "grpcio_tools-1.48.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bdbbe63f6190187de5946891941629912ac8196701ed2253fa91624a397822ec"},
|
||||
{file = "grpcio_tools-1.48.2-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:ae56f133b05b7e5d780ef7e032dd762adad7f3dc8f64adb43ff5bfabd659f435"},
|
||||
{file = "grpcio_tools-1.48.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:f0feb4f2b777fa6377e977faa89c26359d4f31953de15e035505b92f41aa6906"},
|
||||
{file = "grpcio_tools-1.48.2-cp310-cp310-win32.whl", hash = "sha256:80f450272316ca0924545f488c8492649ca3aeb7044d4bf59c426dcdee527f7c"},
|
||||
{file = "grpcio_tools-1.48.2-cp310-cp310-win_amd64.whl", hash = "sha256:21ff50e321736eba22210bf9b94e05391a9ac345f26e7df16333dc75d63e74fb"},
|
||||
{file = "grpcio_tools-1.48.2-cp36-cp36m-linux_armv7l.whl", hash = "sha256:d598ccde6338b2cfbb3124f34c95f03394209013f9b1ed4a5360a736853b1c27"},
|
||||
{file = "grpcio_tools-1.48.2-cp36-cp36m-macosx_10_10_x86_64.whl", hash = "sha256:a43d26714933f23de93ea0bf9c86c66a6ede709b8ca32e357f9e2181703e64ae"},
|
||||
{file = "grpcio_tools-1.48.2-cp36-cp36m-manylinux_2_17_aarch64.whl", hash = "sha256:55fdebc73fb580717656b1bafa4f8eca448726a7aa22726a6c0a7895d2f0f088"},
|
||||
{file = "grpcio_tools-1.48.2-cp36-cp36m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8588819b22d0de3aa1951e1991cc3e4b9aa105eecf6e3e24eb0a2fc8ab958b3e"},
|
||||
{file = "grpcio_tools-1.48.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9771d4d317dca029dfaca7ec9282d8afe731c18bc536ece37fd39b8a974cc331"},
|
||||
{file = "grpcio_tools-1.48.2-cp36-cp36m-musllinux_1_1_i686.whl", hash = "sha256:d886a9e052a038642b3af5d18e6f2085d1656d9788e202dc23258cf3a751e7ca"},
|
||||
{file = "grpcio_tools-1.48.2-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:d77e8b1613876e0d8fd17709509d4ceba13492816426bd156f7e88a4c47e7158"},
|
||||
{file = "grpcio_tools-1.48.2-cp36-cp36m-win32.whl", hash = "sha256:dcaaecdd5e847de5c1d533ea91522bf56c9e6b2dc98cdc0d45f0a1c26e846ea2"},
|
||||
{file = "grpcio_tools-1.48.2-cp36-cp36m-win_amd64.whl", hash = "sha256:0119aabd9ceedfdf41b56b9fdc8284dd85a7f589d087f2694d743f346a368556"},
|
||||
{file = "grpcio_tools-1.48.2-cp37-cp37m-linux_armv7l.whl", hash = "sha256:189be2a9b672300ca6845d94016bdacc052fdbe9d1ae9e85344425efae2ff8ef"},
|
||||
{file = "grpcio_tools-1.48.2-cp37-cp37m-macosx_10_10_x86_64.whl", hash = "sha256:9443f5c30bac449237c3cf99da125f8d6e6c01e17972bc683ee73b75dea95573"},
|
||||
{file = "grpcio_tools-1.48.2-cp37-cp37m-manylinux_2_17_aarch64.whl", hash = "sha256:e0403e095b343431195db1305248b50019ad55d3dd310254431af87e14ef83a2"},
|
||||
{file = "grpcio_tools-1.48.2-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5410d6b601d1404835e34466bd8aee37213489b36ee1aad2276366e265ff29d4"},
|
||||
{file = "grpcio_tools-1.48.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:51be91b7c7056ff9ee48b1eccd4a2840b0126230803a5e09dfc082a5b16a91c1"},
|
||||
{file = "grpcio_tools-1.48.2-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:516eedd5eb7af6326050bc2cfceb3a977b9cc1144f283c43cc4956905285c912"},
|
||||
{file = "grpcio_tools-1.48.2-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:d18599ab572b2f15a8f3db49503272d1bb4fcabb4b4d1214ef03aca1816b20a0"},
|
||||
{file = "grpcio_tools-1.48.2-cp37-cp37m-win32.whl", hash = "sha256:d18ef2adc05a8ef9e58ac46357f6d4ce7e43e077c7eda0a4425773461f9d0e6e"},
|
||||
{file = "grpcio_tools-1.48.2-cp37-cp37m-win_amd64.whl", hash = "sha256:6d9753944e5a6b6b78b76ce9d2ae0fe3f748008c1849deb7fadcb64489d6553b"},
|
||||
{file = "grpcio_tools-1.48.2-cp38-cp38-linux_armv7l.whl", hash = "sha256:3c8749dca04a8d302862ceeb1dfbdd071ee13b281395975f24405a347e5baa57"},
|
||||
{file = "grpcio_tools-1.48.2-cp38-cp38-macosx_10_10_x86_64.whl", hash = "sha256:7307dd2408b82ea545ae63502ec03036b025f449568556ea9a056e06129a7a4e"},
|
||||
{file = "grpcio_tools-1.48.2-cp38-cp38-manylinux_2_17_aarch64.whl", hash = "sha256:072234859f6069dc43a6be8ad6b7d682f4ba1dc2e2db2ebf5c75f62eee0f6dfb"},
|
||||
{file = "grpcio_tools-1.48.2-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6cc298fbfe584de8876a85355efbcf796dfbcfac5948c9560f5df82e79336e2a"},
|
||||
{file = "grpcio_tools-1.48.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f75973a42c710999acd419968bc79f00327e03e855bbe82c6529e003e49af660"},
|
||||
{file = "grpcio_tools-1.48.2-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:f766050e491d0b3203b6b85638015f543816a2eb7d089fc04e86e00f6de0e31d"},
|
||||
{file = "grpcio_tools-1.48.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:8e0d74403484eb77e8df2566a64b8b0b484b5c87903678c381634dd72f252d5e"},
|
||||
{file = "grpcio_tools-1.48.2-cp38-cp38-win32.whl", hash = "sha256:cb75bac0cd43858cb759ef103fe68f8c540cb58b63dda127e710228fec3007b8"},
|
||||
{file = "grpcio_tools-1.48.2-cp38-cp38-win_amd64.whl", hash = "sha256:cabc8b0905cedbc3b2b7b2856334fa35cce3d4bc79ae241cacd8cca8940a5c85"},
|
||||
{file = "grpcio_tools-1.48.2-cp39-cp39-linux_armv7l.whl", hash = "sha256:e712a6d00606ad19abdeae852a7e521d6f6d0dcea843708fecf3a38be16a851e"},
|
||||
{file = "grpcio_tools-1.48.2-cp39-cp39-macosx_10_10_x86_64.whl", hash = "sha256:e7e7668f89fd598c5469bb58e16bfd12b511d9947ccc75aec94da31f62bc3758"},
|
||||
{file = "grpcio_tools-1.48.2-cp39-cp39-manylinux_2_17_aarch64.whl", hash = "sha256:a415fbec67d4ff7efe88794cbe00cf548d0f0a5484cceffe0a0c89d47694c491"},
|
||||
{file = "grpcio_tools-1.48.2-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d96e96ae7361aa51c9cd9c73b677b51f691f98df6086860fcc3c45852d96b0b0"},
|
||||
{file = "grpcio_tools-1.48.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e20d7885a40e68a2bda92908acbabcdf3c14dd386c3845de73ba139e9df1f132"},
|
||||
{file = "grpcio_tools-1.48.2-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:8a5614251c46da07549e24f417cf989710250385e9d80deeafc53a0ee7df6325"},
|
||||
{file = "grpcio_tools-1.48.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:ace0035766fe01a1b096aa050be9f0a9f98402317e7aeff8bfe55349be32a407"},
|
||||
{file = "grpcio_tools-1.48.2-cp39-cp39-win32.whl", hash = "sha256:4fa4300b1be59b046492ed3c5fdb59760bc6433f44c08f50de900f9552ec7461"},
|
||||
{file = "grpcio_tools-1.48.2-cp39-cp39-win_amd64.whl", hash = "sha256:0fb6c1c1e56eb26b224adc028a4204b6ad0f8b292efa28067dff273bbc8b27c4"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
grpcio = ">=1.48.2"
|
||||
protobuf = ">=3.12.0,<4.0dev"
|
||||
setuptools = "*"
|
||||
|
||||
[[package]]
|
||||
name = "gspread"
|
||||
version = "5.11.2"
|
||||
@@ -3031,6 +3111,47 @@ files = [
|
||||
{file = "pycparser-2.21.tar.gz", hash = "sha256:e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pycryptodome"
|
||||
version = "3.19.0"
|
||||
description = "Cryptographic library for Python"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
|
||||
files = [
|
||||
{file = "pycryptodome-3.19.0-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:3006c44c4946583b6de24fe0632091c2653d6256b99a02a3db71ca06472ea1e4"},
|
||||
{file = "pycryptodome-3.19.0-cp27-cp27m-manylinux2010_i686.whl", hash = "sha256:7c760c8a0479a4042111a8dd2f067d3ae4573da286c53f13cf6f5c53a5c1f631"},
|
||||
{file = "pycryptodome-3.19.0-cp27-cp27m-manylinux2010_x86_64.whl", hash = "sha256:08ce3558af5106c632baf6d331d261f02367a6bc3733086ae43c0f988fe042db"},
|
||||
{file = "pycryptodome-3.19.0-cp27-cp27m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:45430dfaf1f421cf462c0dd824984378bef32b22669f2635cb809357dbaab405"},
|
||||
{file = "pycryptodome-3.19.0-cp27-cp27m-musllinux_1_1_aarch64.whl", hash = "sha256:a9bcd5f3794879e91970f2bbd7d899780541d3ff439d8f2112441769c9f2ccea"},
|
||||
{file = "pycryptodome-3.19.0-cp27-cp27m-win32.whl", hash = "sha256:190c53f51e988dceb60472baddce3f289fa52b0ec38fbe5fd20dd1d0f795c551"},
|
||||
{file = "pycryptodome-3.19.0-cp27-cp27m-win_amd64.whl", hash = "sha256:22e0ae7c3a7f87dcdcf302db06ab76f20e83f09a6993c160b248d58274473bfa"},
|
||||
{file = "pycryptodome-3.19.0-cp27-cp27mu-manylinux2010_i686.whl", hash = "sha256:7822f36d683f9ad7bc2145b2c2045014afdbbd1d9922a6d4ce1cbd6add79a01e"},
|
||||
{file = "pycryptodome-3.19.0-cp27-cp27mu-manylinux2010_x86_64.whl", hash = "sha256:05e33267394aad6db6595c0ce9d427fe21552f5425e116a925455e099fdf759a"},
|
||||
{file = "pycryptodome-3.19.0-cp27-cp27mu-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:829b813b8ee00d9c8aba417621b94bc0b5efd18c928923802ad5ba4cf1ec709c"},
|
||||
{file = "pycryptodome-3.19.0-cp27-cp27mu-musllinux_1_1_aarch64.whl", hash = "sha256:fc7a79590e2b5d08530175823a242de6790abc73638cc6dc9d2684e7be2f5e49"},
|
||||
{file = "pycryptodome-3.19.0-cp35-abi3-macosx_10_9_universal2.whl", hash = "sha256:542f99d5026ac5f0ef391ba0602f3d11beef8e65aae135fa5b762f5ebd9d3bfb"},
|
||||
{file = "pycryptodome-3.19.0-cp35-abi3-macosx_10_9_x86_64.whl", hash = "sha256:61bb3ccbf4bf32ad9af32da8badc24e888ae5231c617947e0f5401077f8b091f"},
|
||||
{file = "pycryptodome-3.19.0-cp35-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d49a6c715d8cceffedabb6adb7e0cbf41ae1a2ff4adaeec9432074a80627dea1"},
|
||||
{file = "pycryptodome-3.19.0-cp35-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e249a784cc98a29c77cea9df54284a44b40cafbfae57636dd2f8775b48af2434"},
|
||||
{file = "pycryptodome-3.19.0-cp35-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d033947e7fd3e2ba9a031cb2d267251620964705a013c5a461fa5233cc025270"},
|
||||
{file = "pycryptodome-3.19.0-cp35-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:84c3e4fffad0c4988aef0d5591be3cad4e10aa7db264c65fadbc633318d20bde"},
|
||||
{file = "pycryptodome-3.19.0-cp35-abi3-musllinux_1_1_i686.whl", hash = "sha256:139ae2c6161b9dd5d829c9645d781509a810ef50ea8b657e2257c25ca20efe33"},
|
||||
{file = "pycryptodome-3.19.0-cp35-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:5b1986c761258a5b4332a7f94a83f631c1ffca8747d75ab8395bf2e1b93283d9"},
|
||||
{file = "pycryptodome-3.19.0-cp35-abi3-win32.whl", hash = "sha256:536f676963662603f1f2e6ab01080c54d8cd20f34ec333dcb195306fa7826997"},
|
||||
{file = "pycryptodome-3.19.0-cp35-abi3-win_amd64.whl", hash = "sha256:04dd31d3b33a6b22ac4d432b3274588917dcf850cc0c51c84eca1d8ed6933810"},
|
||||
{file = "pycryptodome-3.19.0-pp27-pypy_73-manylinux2010_x86_64.whl", hash = "sha256:8999316e57abcbd8085c91bc0ef75292c8618f41ca6d2b6132250a863a77d1e7"},
|
||||
{file = "pycryptodome-3.19.0-pp27-pypy_73-win32.whl", hash = "sha256:a0ab84755f4539db086db9ba9e9f3868d2e3610a3948cbd2a55e332ad83b01b0"},
|
||||
{file = "pycryptodome-3.19.0-pp310-pypy310_pp73-macosx_10_9_x86_64.whl", hash = "sha256:0101f647d11a1aae5a8ce4f5fad6644ae1b22bb65d05accc7d322943c69a74a6"},
|
||||
{file = "pycryptodome-3.19.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8c1601e04d32087591d78e0b81e1e520e57a92796089864b20e5f18c9564b3fa"},
|
||||
{file = "pycryptodome-3.19.0-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:506c686a1eee6c00df70010be3b8e9e78f406af4f21b23162bbb6e9bdf5427bc"},
|
||||
{file = "pycryptodome-3.19.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:7919ccd096584b911f2a303c593280869ce1af9bf5d36214511f5e5a1bed8c34"},
|
||||
{file = "pycryptodome-3.19.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:560591c0777f74a5da86718f70dfc8d781734cf559773b64072bbdda44b3fc3e"},
|
||||
{file = "pycryptodome-3.19.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c1cc2f2ae451a676def1a73c1ae9120cd31af25db3f381893d45f75e77be2400"},
|
||||
{file = "pycryptodome-3.19.0-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:17940dcf274fcae4a54ec6117a9ecfe52907ed5e2e438fe712fe7ca502672ed5"},
|
||||
{file = "pycryptodome-3.19.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:d04f5f623a280fbd0ab1c1d8ecbd753193ab7154f09b6161b0f857a1a676c15f"},
|
||||
{file = "pycryptodome-3.19.0.tar.gz", hash = "sha256:bc35d463222cdb4dbebd35e0784155c81e161b9284e567e7e933d722e533331e"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pydgraph"
|
||||
version = "2.0.2"
|
||||
@@ -5025,4 +5146,4 @@ testing = ["coverage (>=5.0.3)", "zope.event", "zope.testing"]
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = ">=3.8,<3.11"
|
||||
content-hash = "e234eb89e41f3d77946fa80bbf2461c730b65110fefd47d77d7a0b27bab7146d"
|
||||
content-hash = "0d446db5da743d01548dd677b534c2195be6c279e853d02f6cf77fcc3c4e801f"
|
||||
|
||||
@@ -137,6 +137,7 @@ thrift-sasl = ">=0.1.0"
|
||||
trino = ">=0.305,<1.0"
|
||||
vertica-python = "1.1.1"
|
||||
xlrd = "2.0.1"
|
||||
e6data-python-connector = "1.1.9"
|
||||
|
||||
[tool.poetry.group.ldap3]
|
||||
optional = true
|
||||
|
||||
154
redash/query_runner/e6data.py
Normal file
154
redash/query_runner/e6data.py
Normal file
@@ -0,0 +1,154 @@
|
||||
import logging
|
||||
|
||||
from redash.query_runner import (
|
||||
TYPE_BOOLEAN,
|
||||
TYPE_DATE,
|
||||
TYPE_DATETIME,
|
||||
TYPE_FLOAT,
|
||||
TYPE_INTEGER,
|
||||
TYPE_STRING,
|
||||
BaseQueryRunner,
|
||||
register,
|
||||
)
|
||||
|
||||
try:
|
||||
from e6data_python_connector import Connection
|
||||
|
||||
enabled = True
|
||||
|
||||
except ImportError:
|
||||
enabled = False
|
||||
|
||||
from redash.utils import json_dumps
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
E6DATA_TYPES_MAPPING = {
|
||||
"INT": TYPE_INTEGER,
|
||||
"BYTE": TYPE_INTEGER,
|
||||
"INTEGER": TYPE_INTEGER,
|
||||
"LONG": TYPE_INTEGER,
|
||||
"SHORT": TYPE_INTEGER,
|
||||
"FLOAT": TYPE_FLOAT,
|
||||
"DOUBLE": TYPE_FLOAT,
|
||||
"STRING": TYPE_STRING,
|
||||
"DATETIME": TYPE_DATETIME,
|
||||
"BINARY": TYPE_INTEGER,
|
||||
"ARRAY": TYPE_STRING,
|
||||
"MAP": TYPE_STRING,
|
||||
"STRUCT": TYPE_STRING,
|
||||
"UNION_TYPE": TYPE_STRING,
|
||||
"DECIMAL_TYPE": TYPE_FLOAT,
|
||||
"DATE": TYPE_DATE,
|
||||
"INT96": TYPE_INTEGER,
|
||||
"BOOLEAN": TYPE_BOOLEAN,
|
||||
"CHAR": TYPE_STRING,
|
||||
}
|
||||
|
||||
|
||||
class e6data(BaseQueryRunner):
|
||||
limit_query = " LIMIT 1000"
|
||||
|
||||
should_annotate_query = False
|
||||
|
||||
def __init__(self, configuration):
|
||||
super().__init__(configuration)
|
||||
self.connection = Connection(
|
||||
host=self.configuration.get("host"),
|
||||
port=self.configuration.get("port"),
|
||||
username=self.configuration.get("username"),
|
||||
database=self.configuration.get("database"),
|
||||
password=self.configuration.get("password"),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def configuration_schema(cls):
|
||||
return {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"host": {"type": "string"},
|
||||
"port": {"type": "number"},
|
||||
"username": {"type": "string"},
|
||||
"password": {"type": "string"},
|
||||
"catalog": {"type": "string"},
|
||||
"database": {"type": "string"},
|
||||
},
|
||||
"order": [
|
||||
"host",
|
||||
"port",
|
||||
"username",
|
||||
"password",
|
||||
"catalog",
|
||||
"database",
|
||||
],
|
||||
"required": ["host", "port", "username", "password", "catalog", "database"],
|
||||
"secret": ["password"],
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def enabled(cls):
|
||||
return enabled
|
||||
|
||||
@classmethod
|
||||
def type(cls):
|
||||
return "e6data"
|
||||
|
||||
def run_query(self, query, user):
|
||||
cursor = None
|
||||
try:
|
||||
cursor = self.connection.cursor(catalog_name=self.configuration.get("catalog"))
|
||||
cursor.execute(query)
|
||||
results = cursor.fetchall()
|
||||
description = cursor.description
|
||||
columns = []
|
||||
for c in description:
|
||||
column_name, column_type = c[0], E6DATA_TYPES_MAPPING.get(c[1], None)
|
||||
columns.append({"name": column_name, "type": column_type})
|
||||
rows = [dict(zip([c["name"] for c in columns], r)) for r in results]
|
||||
data = {"columns": columns, "rows": rows}
|
||||
json_data = json_dumps(data)
|
||||
error = None
|
||||
|
||||
except Exception as error:
|
||||
logger.debug(error)
|
||||
json_data = None
|
||||
finally:
|
||||
if cursor is not None:
|
||||
cursor.clear()
|
||||
cursor.close()
|
||||
|
||||
return json_data, error
|
||||
|
||||
def test_connection(self):
|
||||
self.noop_query = "SELECT 1"
|
||||
|
||||
data, error = self.run_query(self.noop_query, None)
|
||||
|
||||
if error is not None:
|
||||
raise Exception(error)
|
||||
|
||||
def get_schema(self, get_stats=False):
|
||||
tables = self.connection.get_tables(self.configuration.get("catalog"), self.configuration.get("database"))
|
||||
|
||||
schema = list()
|
||||
|
||||
for table_name in tables:
|
||||
columns = self.connection.get_columns(
|
||||
self.configuration.get("catalog"),
|
||||
self.configuration.get("database"),
|
||||
table_name,
|
||||
)
|
||||
columns_with_type = []
|
||||
|
||||
for column in columns:
|
||||
redash_type = E6DATA_TYPES_MAPPING.get(column["fieldType"], None)
|
||||
columns_with_type.append({"name": column["fieldName"], "type": redash_type})
|
||||
|
||||
table_schema = {"name": table_name, "columns": columns_with_type}
|
||||
|
||||
schema.append(table_schema)
|
||||
|
||||
return schema
|
||||
|
||||
|
||||
register(e6data)
|
||||
@@ -337,6 +337,7 @@ default_query_runners = [
|
||||
"redash.query_runner.google_search_console",
|
||||
"redash.query_runner.ignite",
|
||||
"redash.query_runner.oracle",
|
||||
"redash.query_runner.e6data",
|
||||
]
|
||||
|
||||
enabled_query_runners = array_from_string(
|
||||
|
||||
92
tests/query_runner/test_e6data.py
Normal file
92
tests/query_runner/test_e6data.py
Normal file
@@ -0,0 +1,92 @@
|
||||
from unittest.mock import patch
|
||||
|
||||
from redash.query_runner import TYPE_INTEGER, TYPE_STRING
|
||||
from redash.query_runner.e6data import e6data
|
||||
from redash.utils import json_dumps
|
||||
|
||||
runner = e6data(
|
||||
{
|
||||
"username": "test_user",
|
||||
"password": "test_password",
|
||||
"host": "test_host",
|
||||
"port": 80,
|
||||
"catalog": "test_catalog",
|
||||
"database": "test_database",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@patch("e6data_python_connector.e6data_grpc.Cursor")
|
||||
def test_run_query(mock_cursor):
|
||||
query = "SELECT * FROM test_table"
|
||||
user = None
|
||||
mock_cursor.return_value.fetchall.return_value = [[1, "John"]]
|
||||
mock_cursor.return_value.description = [
|
||||
("id", "INT", None, None, None, None, True),
|
||||
("name", "STRING", None, None, None, None, True),
|
||||
]
|
||||
|
||||
json_data, error = runner.run_query(query, user)
|
||||
|
||||
expected_json_data = json_dumps(
|
||||
{
|
||||
"columns": [
|
||||
{"name": "id", "type": TYPE_INTEGER},
|
||||
{"name": "name", "type": TYPE_STRING},
|
||||
],
|
||||
"rows": [{"id": 1, "name": "John"}],
|
||||
}
|
||||
)
|
||||
|
||||
assert json_data == expected_json_data
|
||||
|
||||
|
||||
@patch("e6data_python_connector.e6data_grpc.Cursor")
|
||||
def test_test_connection(mock_cursor):
|
||||
query = "SELECT 1"
|
||||
user = None
|
||||
mock_cursor.return_value.fetchall.return_value = [[1]]
|
||||
mock_cursor.return_value.description = [("EXPR$0", "INTEGER", None, None, None, None, True)]
|
||||
|
||||
json_data, error = runner.run_query(query, user)
|
||||
|
||||
expected_json_data = json_dumps({"columns": [{"name": "EXPR$0", "type": TYPE_INTEGER}], "rows": [{"EXPR$0": 1}]})
|
||||
|
||||
assert json_data == expected_json_data
|
||||
|
||||
|
||||
@patch("e6data_python_connector.Connection.get_tables")
|
||||
@patch("e6data_python_connector.Connection.get_columns")
|
||||
def test_get_schema(mock_get_columns, mock_get_tables):
|
||||
mock_get_tables.return_value = ["table1", "table2"]
|
||||
mock_get_columns.side_effect = [
|
||||
[
|
||||
{"fieldName": "id", "fieldType": "INT"},
|
||||
{"fieldName": "name", "fieldType": "STRING"},
|
||||
],
|
||||
[
|
||||
{"fieldName": "age", "fieldType": "INT"},
|
||||
{"fieldName": "city", "fieldType": "STRING"},
|
||||
],
|
||||
]
|
||||
|
||||
schema = runner.get_schema()
|
||||
|
||||
expected_schema = [
|
||||
{
|
||||
"name": "table1",
|
||||
"columns": [
|
||||
{"name": "id", "type": TYPE_INTEGER},
|
||||
{"name": "name", "type": TYPE_STRING},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "table2",
|
||||
"columns": [
|
||||
{"name": "age", "type": TYPE_INTEGER},
|
||||
{"name": "city", "type": TYPE_STRING},
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
assert schema == expected_schema
|
||||
Reference in New Issue
Block a user