Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
059533b4
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
059533b4
编写于
10月 12, 2021
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-6129<feature> add json nchar & json binary from python connector & fix json bug
上级
dfb7b6ee
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
36 addition
and
11 deletion
+36
-11
src/connector/python/taos/bind.py
src/connector/python/taos/bind.py
+23
-4
src/connector/python/taos/constants.py
src/connector/python/taos/constants.py
+2
-1
src/connector/python/taos/cursor.py
src/connector/python/taos/cursor.py
+5
-2
src/connector/python/taos/field.py
src/connector/python/taos/field.py
+4
-2
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+2
-2
未找到文件。
src/connector/python/taos/bind.py
浏览文件 @
059533b4
...
...
@@ -124,7 +124,7 @@ class TaosBind(ctypes.Structure):
self
.
buffer_length
=
length
self
.
length
=
pointer
(
c_size_t
(
self
.
buffer_length
))
def
json
(
self
,
value
):
def
json
_binary
(
self
,
value
):
buffer
=
None
length
=
0
if
isinstance
(
value
,
str
):
...
...
@@ -134,7 +134,22 @@ class TaosBind(ctypes.Structure):
else
:
buffer
=
value
length
=
len
(
value
)
self
.
buffer_type
=
FieldType
.
C_JSON
self
.
buffer_type
=
FieldType
.
C_JSON_BINARY
self
.
buffer
=
cast
(
buffer
,
c_void_p
)
self
.
buffer_length
=
length
self
.
length
=
pointer
(
c_size_t
(
self
.
buffer_length
))
def
json_nchar
(
self
,
value
):
buffer
=
None
length
=
0
if
isinstance
(
value
,
str
):
bytes
=
value
.
encode
(
"utf-8"
)
buffer
=
create_string_buffer
(
bytes
)
length
=
len
(
bytes
)
else
:
buffer
=
value
length
=
len
(
value
)
self
.
buffer_type
=
FieldType
.
C_JSON_NCHAR
self
.
buffer
=
cast
(
buffer
,
c_void_p
)
self
.
buffer_length
=
length
self
.
length
=
pointer
(
c_size_t
(
self
.
buffer_length
))
...
...
@@ -371,9 +386,13 @@ class TaosMultiBind(ctypes.Structure):
self
.
buffer_type
=
FieldType
.
C_NCHAR
self
.
_str_to_buffer
(
values
)
def
json
(
self
,
values
):
def
json_binary
(
self
,
values
):
self
.
buffer_type
=
FieldType
.
C_JSON_BINARY
self
.
_str_to_buffer
(
values
)
def
json_nchar
(
self
,
values
):
# type: (list[str]) -> None
self
.
buffer_type
=
FieldType
.
C_JSON
self
.
buffer_type
=
FieldType
.
C_JSON
_NCHAR
self
.
_str_to_buffer
(
values
)
def
tinyint_unsigned
(
self
,
values
):
...
...
src/connector/python/taos/constants.py
浏览文件 @
059533b4
...
...
@@ -25,7 +25,8 @@ class FieldType(object):
C_SMALLINT_UNSIGNED
=
12
C_INT_UNSIGNED
=
13
C_BIGINT_UNSIGNED
=
14
C_JSON
=
15
C_JSON_BINARY
=
15
C_JSON_NCHAR
=
16
# NULL value definition
# NOTE: These values should change according to C definition in tsdb.h
C_BOOL_NULL
=
0x02
...
...
src/connector/python/taos/cursor.py
浏览文件 @
059533b4
...
...
@@ -188,8 +188,11 @@ class TaosCursor(object):
if
dataType
.
upper
()
==
"NCHAR"
:
if
self
.
_description
[
col
][
1
]
==
FieldType
.
C_NCHAR
:
return
True
if
dataType
.
upper
()
==
"JSON"
:
if
self
.
_description
[
col
][
1
]
==
FieldType
.
C_JSON
:
if
dataType
.
upper
()
==
"JSON BINARY"
:
if
self
.
_description
[
col
][
1
]
==
FieldType
.
C_JSON_BINARY
:
return
True
if
dataType
.
upper
()
==
"JSON NCHAR"
:
if
self
.
_description
[
col
][
1
]
==
FieldType
.
C_JSON_NCHAR
:
return
True
return
False
...
...
src/connector/python/taos/field.py
浏览文件 @
059533b4
...
...
@@ -207,7 +207,8 @@ CONVERT_FUNC = {
FieldType
.
C_SMALLINT_UNSIGNED
:
_crow_smallint_unsigned_to_python
,
FieldType
.
C_INT_UNSIGNED
:
_crow_int_unsigned_to_python
,
FieldType
.
C_BIGINT_UNSIGNED
:
_crow_bigint_unsigned_to_python
,
FieldType
.
C_JSON
:
_crow_nchar_to_python
,
FieldType
.
C_JSON_NCHAR
:
_crow_nchar_to_python
,
FieldType
.
C_JSON_BINARY
:
_crow_binary_to_python
,
}
CONVERT_FUNC_BLOCK
=
{
...
...
@@ -225,7 +226,8 @@ CONVERT_FUNC_BLOCK = {
FieldType
.
C_SMALLINT_UNSIGNED
:
_crow_smallint_unsigned_to_python
,
FieldType
.
C_INT_UNSIGNED
:
_crow_int_unsigned_to_python
,
FieldType
.
C_BIGINT_UNSIGNED
:
_crow_bigint_unsigned_to_python
,
FieldType
.
C_JSON
:
_crow_nchar_to_python_block
,
FieldType
.
C_JSON_NCHAR
:
_crow_nchar_to_python_block
,
FieldType
.
C_JSON_BINARY
:
_crow_binary_to_python_block
,
}
# Corresponding TAOS_FIELD structure in C
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
059533b4
...
...
@@ -2678,7 +2678,7 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int
static
int32_t
getAllTableList
(
STable
*
pSuperTable
,
SArray
*
list
)
{
STSchema
*
pTagSchema
=
tsdbGetTableTagSchema
(
pSuperTable
);
if
(
pTagSchema
->
numOfCols
==
1
&&
IS_JSON_DATA_TYPE
(
pTagSchema
->
columns
[
0
].
type
)){
if
(
pTagSchema
&&
pTagSchema
->
numOfCols
==
1
&&
IS_JSON_DATA_TYPE
(
pTagSchema
->
columns
[
0
].
type
)){
SArray
**
pRecord
=
taosHashIterate
(
pSuperTable
->
jsonKeyMap
,
NULL
);
SArray
*
tablist
=
taosArrayInit
(
32
,
sizeof
(
JsonMapValue
));
...
...
@@ -4081,7 +4081,7 @@ static FORCE_INLINE int32_t tsdbGetJsonTagDataFromId(void *param, int32_t id, ch
if
(
id
==
TSDB_TBNAME_COLUMN_INDEX
)
{
*
data
=
TABLE_NAME
(
pTable
);
}
else
{
void
*
jsonData
=
getJsonTagValue
(
pTable
,
name
,
strlen
(
name
),
pTable
->
tagSchema
->
columns
->
type
);
void
*
jsonData
=
getJsonTagValue
(
pTable
,
name
,
strlen
(
name
),
pTable
->
pSuper
->
tagSchema
->
columns
->
type
);
if
(
jsonData
!=
NULL
)
jsonData
+=
CHAR_BYTES
;
// jump type
*
data
=
jsonData
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录