This is an automated email from the ASF dual-hosted git repository. jiangtian pushed a commit to branch add_metaquery_python in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
commit aae3d0ae50884161dbcbf76654c6edfc72c5b3f6 Author: jt2594838 <[email protected]> AuthorDate: Thu Dec 19 12:19:51 2019 +0800 add metadata query in python example --- client-py/src/client_example.py | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/client-py/src/client_example.py b/client-py/src/client_example.py index a6a20a2..30e8407 100644 --- a/client-py/src/client_example.py +++ b/client-py/src/client_example.py @@ -27,7 +27,7 @@ from iotdb.rpc.TSIService import Client, TSCreateTimeseriesReq, TSInsertionReq, TSBatchInsertionReq, TSExecuteStatementReq, TSOpenSessionReq, TSQueryDataSet, \ TSFetchResultsReq, TSCloseOperationReq, \ TSCloseSessionReq -from iotdb.rpc.ttypes import TSProtocolVersion +from iotdb.rpc.ttypes import TSProtocolVersion, TSFetchMetadataReq TSDataType = { 'BOOLEAN': 0, @@ -59,6 +59,20 @@ Compressor = { 'PLA': 6 } + +class Enum: + def __init__(self): + pass + + +MetaQueryTypes = Enum() +MetaQueryTypes.CATALOG_COLUMN = "COLUMN" +MetaQueryTypes.CATALOG_TIMESERIES = "SHOW_TIMESERIES" +MetaQueryTypes.CATALOG_STORAGE_GROUP = "SHOW_STORAGE_GROUP" +MetaQueryTypes.CATALOG_DEVICES = "SHOW_DEVICES" +MetaQueryTypes.CATALOG_CHILD_PATHS = "SHOW_CHILD_PATHS" + + # used to do `and` operation with bitmap to judge whether the value is null flag = 0x80 @@ -278,5 +292,27 @@ if __name__ == '__main__': closeReq.queryId = queryId client.closeOperation(closeReq) + # query metadata + metaReq = TSFetchMetadataReq(sessionId=sessionId, type=MetaQueryTypes.CATALOG_DEVICES) + print(client.fetchMetadata(metaReq).devices) + + metaReq = TSFetchMetadataReq(sessionId=sessionId, + type=MetaQueryTypes.CATALOG_TIMESERIES, + columnPath='root') + print(client.fetchMetadata(metaReq).timeseriesList) + + metaReq = TSFetchMetadataReq(sessionId=sessionId, + type=MetaQueryTypes.CATALOG_CHILD_PATHS, + columnPath='root') + print(client.fetchMetadata(metaReq).childPaths) + + metaReq = TSFetchMetadataReq(sessionId=sessionId, type=MetaQueryTypes.CATALOG_STORAGE_GROUP) + print(client.fetchMetadata(metaReq).storageGroups) + + metaReq = TSFetchMetadataReq(sessionId=sessionId, + type=MetaQueryTypes.CATALOG_COLUMN, + columnPath='root.group1.s1') + print(client.fetchMetadata(metaReq).dataType) + # and do not forget to close the session before exiting client.closeSession(TSCloseSessionReq(sessionId))
