Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_22812535
incubator-superset
提交
284a0ccc
I
incubator-superset
项目概览
qq_22812535
/
incubator-superset
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
incubator-superset
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
284a0ccc
编写于
1月 13, 2019
作者:
C
Chinh Nguyen
提交者:
Maxime Beauchemin
1月 13, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add fix for pyodbc+mssql (#6621)
* add fix for odbc+mssql * fix for pylint/pep8
上级
ae6217ba
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
51 addition
and
0 deletion
+51
-0
superset/db_engine_specs.py
superset/db_engine_specs.py
+7
-0
tests/core_tests.py
tests/core_tests.py
+32
-0
tests/fixtures/pyodbcRow.py
tests/fixtures/pyodbcRow.py
+12
-0
未找到文件。
superset/db_engine_specs.py
浏览文件 @
284a0ccc
...
...
@@ -1287,6 +1287,13 @@ class MssqlEngineSpec(BaseEngineSpec):
def
convert_dttm
(
cls
,
target_type
,
dttm
):
return
"CONVERT(DATETIME, '{}', 126)"
.
format
(
dttm
.
isoformat
())
@
classmethod
def
fetch_data
(
cls
,
cursor
,
limit
):
data
=
super
(
MssqlEngineSpec
,
cls
).
fetch_data
(
cursor
,
limit
)
if
len
(
data
)
!=
0
and
type
(
data
[
0
]).
__name__
==
'Row'
:
data
=
[[
elem
for
elem
in
r
]
for
r
in
data
]
return
data
class
AthenaEngineSpec
(
BaseEngineSpec
):
engine
=
'awsathena'
...
...
tests/core_tests.py
浏览文件 @
284a0ccc
...
...
@@ -19,12 +19,14 @@ import sqlalchemy as sqla
from
superset
import
dataframe
,
db
,
jinja_context
,
security_manager
,
sql_lab
from
superset.connectors.sqla.models
import
SqlaTable
from
superset.db_engine_specs
import
BaseEngineSpec
from
superset.db_engine_specs
import
MssqlEngineSpec
from
superset.models
import
core
as
models
from
superset.models.sql_lab
import
Query
from
superset.utils
import
core
as
utils
from
superset.utils.core
import
get_main_database
from
superset.views.core
import
DatabaseView
from
.base_tests
import
SupersetTestCase
from
.fixtures.pyodbcRow
import
Row
class
CoreTests
(
SupersetTestCase
):
...
...
@@ -673,6 +675,36 @@ class CoreTests(SupersetTestCase):
{
'data'
:
pd
.
Timestamp
(
'2017-11-18 22:06:30.061810+0100'
,
tz
=
tz
)},
)
def
test_mssql_engine_spec_pymssql
(
self
):
# Test for case when tuple is returned (pymssql)
data
=
[(
1
,
1
,
datetime
.
datetime
(
2017
,
10
,
19
,
23
,
39
,
16
,
660000
)),
(
2
,
2
,
datetime
.
datetime
(
2018
,
10
,
19
,
23
,
39
,
16
,
660000
))]
df
=
dataframe
.
SupersetDataFrame
(
list
(
data
),
[[
'col1'
],
[
'col2'
],
[
'col3'
]],
MssqlEngineSpec
)
data
=
df
.
data
self
.
assertEqual
(
len
(
data
),
2
)
self
.
assertEqual
(
data
[
0
],
{
'col1'
:
1
,
'col2'
:
1
,
'col3'
:
pd
.
Timestamp
(
'2017-10-19 23:39:16.660000'
)})
def
test_mssql_engine_spec_odbc
(
self
):
# Test for case when pyodbc.Row is returned (msodbc driver)
data
=
[
Row
((
1
,
1
,
datetime
.
datetime
(
2017
,
10
,
19
,
23
,
39
,
16
,
660000
))),
Row
((
2
,
2
,
datetime
.
datetime
(
2018
,
10
,
19
,
23
,
39
,
16
,
660000
)))]
df
=
dataframe
.
SupersetDataFrame
(
list
(
data
),
[[
'col1'
],
[
'col2'
],
[
'col3'
]],
MssqlEngineSpec
)
data
=
df
.
data
self
.
assertEqual
(
len
(
data
),
2
)
self
.
assertEqual
(
data
[
0
],
{
'col1'
:
1
,
'col2'
:
1
,
'col3'
:
pd
.
Timestamp
(
'2017-10-19 23:39:16.660000'
)})
def
test_comments_in_sqlatable_query
(
self
):
clean_query
=
"SELECT '/* val 1 */' as c1, '-- val 2' as c2 FROM tbl"
commented_query
=
'/* comment 1 */'
+
clean_query
+
'-- comment 2'
...
...
tests/fixtures/pyodbcRow.py
0 → 100644
浏览文件 @
284a0ccc
# pylint: disable=C,R,W
class
Row
(
object
):
def
__init__
(
self
,
values
):
self
.
values
=
values
def
__name__
(
self
):
return
'Row'
def
__iter__
(
self
):
return
(
item
for
item
in
self
.
values
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录