Skip to content

Commit e0cd2b4

Browse files
authored
Merge pull request #22 from ydb-platform/support-null-type
support null type in queries
2 parents 46f0157 + 0aa38f2 commit e0cd2b4

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## 2.2.0 ##
22

33
* allow to refer endpoints by node id
4+
* support null type in queries
45

56
## 2.1.0 ##
67

ydb/convert.py

+5
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,15 @@ def _primitive_type_to_native(type_pb):
256256
return _primitive_type_by_id.get(type_pb.type_id)
257257

258258

259+
def _null_type_factory(type_pb):
260+
return types.NullType()
261+
262+
259263
_type_to_native_map = {
260264
"optional_type": _optional_type_to_native,
261265
"type_id": _primitive_type_to_native,
262266
"decimal_type": _decimal_type_to_native,
267+
"null_type": _null_type_factory,
263268
}
264269

265270

ydb/types.py

+15
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from datetime import date, datetime
88
import uuid
99
import struct
10+
from google.protobuf import struct_pb2
1011

1112

1213
if six.PY3:
@@ -214,6 +215,20 @@ def __str__(self):
214215
return "Decimal(%d,%d)" % (self._precision, self._scale)
215216

216217

218+
class NullType(AbstractTypeBuilder):
219+
__slots__ = ("_repr", "_proto")
220+
221+
def __init__(self):
222+
self._proto = _apis.ydb_value.Type(null_type=struct_pb2.NULL_VALUE)
223+
224+
@property
225+
def proto(self):
226+
return self._proto
227+
228+
def __str__(self):
229+
return "NullType"
230+
231+
217232
class OptionalType(AbstractTypeBuilder):
218233
__slots__ = ("_repr", "_proto", "_item")
219234

0 commit comments

Comments
 (0)