You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by "HTHou (via GitHub)" <gi...@apache.org> on 2024/09/09 03:30:56 UTC

[PR] [Pyclient] support table model [iotdb]

HTHou opened a new pull request, #13443:
URL: https://github.com/apache/iotdb/pull/13443

   ## Description
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Py-Client] Support table model with python client [iotdb]

Posted by "jt2594838 (via GitHub)" <gi...@apache.org>.
jt2594838 commented on code in PR #13443:
URL: https://github.com/apache/iotdb/pull/13443#discussion_r1751132875


##########
iotdb-client/client-py/iotdb/Session.py:
##########
@@ -1058,6 +1076,35 @@ def insert_aligned_tablets(self, tablet_lst):
                         self.connection_error_msg()
                     ) from None
 
+    def insert_relational_tablet(self, tablet):
+        """
+        insert one tablet, in a tablet, for each timestamp, the number of measurements is same
+            for example three records in the same device can form a tablet:
+                timestamps,     m1,    m2,     m3
+                         1,  125.3,  True,  text1
+                         2,  111.6, False,  text2
+                         3,  688.6,  True,  text3
+        :param tablet: a tablet specified above
+        """

Review Comment:
   Better to explicitly indicate how devices are expressed in a relational Tablet (i.e., ID columns) in the example, which is quite different from the tree Tablet.



##########
iotdb-client/client-py/TableModelSessionPoolExample.py:
##########
@@ -0,0 +1,160 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+import threading
+
+import numpy as np
+
+from iotdb.SessionPool import PoolConfig, SessionPool
+from iotdb.utils.IoTDBConstants import TSDataType
+from iotdb.utils.NumpyTablet import NumpyTablet
+from iotdb.utils.Tablet import ColumnType, Tablet
+
+
+def prepare_data():
+    print("create database")
+    # Get a session from the pool
+    session = session_pool.get_session()
+    session.execute_non_query_statement("CREATE DATABASE IF NOT EXISTS db1")
+    session.execute_non_query_statement('USE "db1"')
+    session.execute_non_query_statement(
+        "CREATE TABLE table0 (id1 string id, attr1 string attribute, "
+        + "m1 double "
+        + "measurement)"
+    )
+    session.execute_non_query_statement(
+        "CREATE TABLE table1 (id1 string id, attr1 string attribute, "
+        + "m1 double "
+        + "measurement)"
+    )
+
+    print("now the tables are:")
+    # show result
+    res = session.execute_query_statement("SHOW TABLES")
+    while res.has_next():
+        print(res.next())
+
+    session_pool.put_back(session)
+
+
+def insert_data(num: int):
+    print("insert data for table" + str(num))
+    # Get a session from the pool
+    session = session_pool.get_session()
+    column_names = [
+        "id1",
+        "attr1",
+        "m1",
+    ]
+    data_types = [
+        TSDataType.STRING,
+        TSDataType.STRING,
+        TSDataType.DOUBLE,
+    ]
+    column_types = [ColumnType.ID, ColumnType.ATTRIBUTE, ColumnType.MEASUREMENT]
+    timestamps = []
+    values = []
+    for row in range(15):
+        timestamps.append(row)
+        values.append(["id:" + str(row), "attr:" + str(row), row * 1.0])
+    tablet = Tablet(
+        "table" + str(num), column_names, data_types, values, timestamps, column_types
+    )
+    session.insert_relational_tablet(tablet)
+    session.execute_non_query_statement("FLush")
+
+    np_timestamps = np.arange(15, 30, dtype=np.dtype(">i8"))
+    np_values = [
+        np.array(["id:{}".format(i) for i in range(15, 30)]),
+        np.array(["attr:{}".format(i) for i in range(15, 30)]),
+        np.linspace(15.0, 29.0, num=15, dtype=TSDataType.DOUBLE.np_dtype()),
+    ]
+
+    np_tablet = NumpyTablet(
+        "table" + str(num),
+        column_names,
+        data_types,
+        np_values,
+        np_timestamps,
+        column_types=column_types,
+    )
+    session.insert_relational_tablet(np_tablet)
+    session_pool.put_back(session)
+
+
+def query_data():
+    # Get a session from the pool
+    session = session_pool.get_session()
+
+    print("get data from table0")
+    res = session.execute_query_statement("select * from table0")
+    while res.has_next():
+        print(res.next())
+
+    print("get data from table1")
+    res = session.execute_query_statement("select * from table0")
+    while res.has_next():
+        print(res.next())
+
+    session_pool.put_back(session)
+
+
+def delete_data():
+    session = session_pool.get_session()
+    session.execute_non_query_statement("drop database db1")
+    print("data has been deleted. now the devices are:")
+    res = session.execute_statement("show databases")

Review Comment:
   devices -> databases



##########
iotdb-client/client-py/TableModelSessionPoolExample.py:
##########
@@ -0,0 +1,160 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+import threading
+
+import numpy as np
+
+from iotdb.SessionPool import PoolConfig, SessionPool
+from iotdb.utils.IoTDBConstants import TSDataType
+from iotdb.utils.NumpyTablet import NumpyTablet
+from iotdb.utils.Tablet import ColumnType, Tablet
+
+
+def prepare_data():
+    print("create database")
+    # Get a session from the pool
+    session = session_pool.get_session()
+    session.execute_non_query_statement("CREATE DATABASE IF NOT EXISTS db1")
+    session.execute_non_query_statement('USE "db1"')
+    session.execute_non_query_statement(
+        "CREATE TABLE table0 (id1 string id, attr1 string attribute, "
+        + "m1 double "
+        + "measurement)"
+    )
+    session.execute_non_query_statement(
+        "CREATE TABLE table1 (id1 string id, attr1 string attribute, "
+        + "m1 double "
+        + "measurement)"
+    )
+
+    print("now the tables are:")
+    # show result
+    res = session.execute_query_statement("SHOW TABLES")
+    while res.has_next():
+        print(res.next())
+
+    session_pool.put_back(session)
+
+
+def insert_data(num: int):
+    print("insert data for table" + str(num))
+    # Get a session from the pool
+    session = session_pool.get_session()
+    column_names = [
+        "id1",
+        "attr1",
+        "m1",
+    ]
+    data_types = [
+        TSDataType.STRING,
+        TSDataType.STRING,
+        TSDataType.DOUBLE,
+    ]
+    column_types = [ColumnType.ID, ColumnType.ATTRIBUTE, ColumnType.MEASUREMENT]
+    timestamps = []
+    values = []
+    for row in range(15):
+        timestamps.append(row)
+        values.append(["id:" + str(row), "attr:" + str(row), row * 1.0])
+    tablet = Tablet(
+        "table" + str(num), column_names, data_types, values, timestamps, column_types
+    )
+    session.insert_relational_tablet(tablet)
+    session.execute_non_query_statement("FLush")
+
+    np_timestamps = np.arange(15, 30, dtype=np.dtype(">i8"))
+    np_values = [
+        np.array(["id:{}".format(i) for i in range(15, 30)]),
+        np.array(["attr:{}".format(i) for i in range(15, 30)]),
+        np.linspace(15.0, 29.0, num=15, dtype=TSDataType.DOUBLE.np_dtype()),
+    ]
+
+    np_tablet = NumpyTablet(
+        "table" + str(num),
+        column_names,
+        data_types,
+        np_values,
+        np_timestamps,
+        column_types=column_types,
+    )
+    session.insert_relational_tablet(np_tablet)
+    session_pool.put_back(session)
+
+
+def query_data():
+    # Get a session from the pool
+    session = session_pool.get_session()
+
+    print("get data from table0")
+    res = session.execute_query_statement("select * from table0")
+    while res.has_next():
+        print(res.next())
+
+    print("get data from table1")
+    res = session.execute_query_statement("select * from table0")
+    while res.has_next():
+        print(res.next())
+
+    session_pool.put_back(session)
+
+
+def delete_data():
+    session = session_pool.get_session()
+    session.execute_non_query_statement("drop database db1")
+    print("data has been deleted. now the devices are:")
+    res = session.execute_statement("show databases")
+    while res.has_next():
+        print(res.next())
+    session_pool.put_back(session)
+
+
+ip = "127.0.0.1"
+port = "6667"
+username = "root"
+password = "root"
+pool_config = PoolConfig(
+    node_urls=["127.0.0.1:6667", "127.0.0.1:6668", "127.0.0.1:6669"],
+    user_name=username,
+    password=password,
+    fetch_size=1024,
+    time_zone="UTC+8",
+    max_retry=3,
+    sql_dialect="table",
+    database="db1",
+)
+max_pool_size = 5
+wait_timeout_in_ms = 3000
+
+# Create a session pool
+session_pool = SessionPool(pool_config, max_pool_size, wait_timeout_in_ms)

Review Comment:
   Just curious: what is the standard of putting configs in `pool_config` or not? ` max_pool_size` and `wait_timeout_in_ms` seem perfectly fit in `pool_config` but they are listed separately.



##########
iotdb-client/client-py/iotdb/Session.py:
##########
@@ -1058,6 +1076,35 @@ def insert_aligned_tablets(self, tablet_lst):
                         self.connection_error_msg()
                     ) from None
 
+    def insert_relational_tablet(self, tablet):
+        """
+        insert one tablet, in a tablet, for each timestamp, the number of measurements is same
+            for example three records in the same device can form a tablet:
+                timestamps,     m1,    m2,     m3
+                         1,  125.3,  True,  text1
+                         2,  111.6, False,  text2
+                         3,  688.6,  True,  text3
+        :param tablet: a tablet specified above
+        """
+        request = self.gen_insert_relational_tablet_req(tablet)
+        try:
+            connection = self.get_connection(tablet.get_device_id())

Review Comment:
   Better to add some comments to explain that it is the table name here actually, or change the method name to a more generic one.



##########
iotdb-client/client-py/iotdb/utils/Field.py:
##########
@@ -38,13 +38,19 @@ def copy(field):
                 output.set_bool_value(field.get_bool_value())
             elif output.get_data_type() == TSDataType.INT32:
                 output.set_int_value(field.get_int_value())
-            elif output.get_data_type() == TSDataType.INT64:
+            elif (
+                output.get_data_type() == TSDataType.INT64
+                or output.get_data_type() == TSDataType.TIMESTAMP
+            ):
                 output.set_long_value(field.get_long_value())
             elif output.get_data_type() == TSDataType.FLOAT:
                 output.set_float_value(field.get_float_value())
             elif output.get_data_type() == TSDataType.DOUBLE:
                 output.set_double_value(field.get_double_value())
-            elif output.get_data_type() == TSDataType.TEXT:
+            elif (
+                output.get_data_type() == TSDataType.TEXT
+                or output.get_data_type() == TSDataType.STRING
+            ):
                 output.set_binary_value(field.get_binary_value())
             else:

Review Comment:
   Should DATE and BLOB be processed here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [PyClient] Support table model with python client [iotdb]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #13443:
URL: https://github.com/apache/iotdb/pull/13443#issuecomment-2337797839

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Py-Client] Support table model with python client [iotdb]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #13443:
URL: https://github.com/apache/iotdb/pull/13443#issuecomment-2338167168

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [PyClient] Support table model with python client [iotdb]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #13443:
URL: https://github.com/apache/iotdb/pull/13443#issuecomment-2338070790

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Py-Client] Support table model with python client [iotdb]

Posted by "HTHou (via GitHub)" <gi...@apache.org>.
HTHou commented on code in PR #13443:
URL: https://github.com/apache/iotdb/pull/13443#discussion_r1751219747


##########
iotdb-client/client-py/iotdb/Session.py:
##########
@@ -1058,6 +1076,35 @@ def insert_aligned_tablets(self, tablet_lst):
                         self.connection_error_msg()
                     ) from None
 
+    def insert_relational_tablet(self, tablet):
+        """
+        insert one tablet, in a tablet, for each timestamp, the number of measurements is same
+            for example three records in the same device can form a tablet:
+                timestamps,     m1,    m2,     m3
+                         1,  125.3,  True,  text1
+                         2,  111.6, False,  text2
+                         3,  688.6,  True,  text3
+        :param tablet: a tablet specified above
+        """

Review Comment:
   fixed



##########
iotdb-client/client-py/iotdb/Session.py:
##########
@@ -1058,6 +1076,35 @@ def insert_aligned_tablets(self, tablet_lst):
                         self.connection_error_msg()
                     ) from None
 
+    def insert_relational_tablet(self, tablet):
+        """
+        insert one tablet, in a tablet, for each timestamp, the number of measurements is same
+            for example three records in the same device can form a tablet:
+                timestamps,     m1,    m2,     m3
+                         1,  125.3,  True,  text1
+                         2,  111.6, False,  text2
+                         3,  688.6,  True,  text3
+        :param tablet: a tablet specified above
+        """
+        request = self.gen_insert_relational_tablet_req(tablet)
+        try:
+            connection = self.get_connection(tablet.get_device_id())

Review Comment:
   fixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Py-Client] Support table model with python client [iotdb]

Posted by "HTHou (via GitHub)" <gi...@apache.org>.
HTHou commented on code in PR #13443:
URL: https://github.com/apache/iotdb/pull/13443#discussion_r1751148063


##########
iotdb-client/client-py/TableModelSessionPoolExample.py:
##########
@@ -0,0 +1,160 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+import threading
+
+import numpy as np
+
+from iotdb.SessionPool import PoolConfig, SessionPool
+from iotdb.utils.IoTDBConstants import TSDataType
+from iotdb.utils.NumpyTablet import NumpyTablet
+from iotdb.utils.Tablet import ColumnType, Tablet
+
+
+def prepare_data():
+    print("create database")
+    # Get a session from the pool
+    session = session_pool.get_session()
+    session.execute_non_query_statement("CREATE DATABASE IF NOT EXISTS db1")
+    session.execute_non_query_statement('USE "db1"')
+    session.execute_non_query_statement(
+        "CREATE TABLE table0 (id1 string id, attr1 string attribute, "
+        + "m1 double "
+        + "measurement)"
+    )
+    session.execute_non_query_statement(
+        "CREATE TABLE table1 (id1 string id, attr1 string attribute, "
+        + "m1 double "
+        + "measurement)"
+    )
+
+    print("now the tables are:")
+    # show result
+    res = session.execute_query_statement("SHOW TABLES")
+    while res.has_next():
+        print(res.next())
+
+    session_pool.put_back(session)
+
+
+def insert_data(num: int):
+    print("insert data for table" + str(num))
+    # Get a session from the pool
+    session = session_pool.get_session()
+    column_names = [
+        "id1",
+        "attr1",
+        "m1",
+    ]
+    data_types = [
+        TSDataType.STRING,
+        TSDataType.STRING,
+        TSDataType.DOUBLE,
+    ]
+    column_types = [ColumnType.ID, ColumnType.ATTRIBUTE, ColumnType.MEASUREMENT]
+    timestamps = []
+    values = []
+    for row in range(15):
+        timestamps.append(row)
+        values.append(["id:" + str(row), "attr:" + str(row), row * 1.0])
+    tablet = Tablet(
+        "table" + str(num), column_names, data_types, values, timestamps, column_types
+    )
+    session.insert_relational_tablet(tablet)
+    session.execute_non_query_statement("FLush")
+
+    np_timestamps = np.arange(15, 30, dtype=np.dtype(">i8"))
+    np_values = [
+        np.array(["id:{}".format(i) for i in range(15, 30)]),
+        np.array(["attr:{}".format(i) for i in range(15, 30)]),
+        np.linspace(15.0, 29.0, num=15, dtype=TSDataType.DOUBLE.np_dtype()),
+    ]
+
+    np_tablet = NumpyTablet(
+        "table" + str(num),
+        column_names,
+        data_types,
+        np_values,
+        np_timestamps,
+        column_types=column_types,
+    )
+    session.insert_relational_tablet(np_tablet)
+    session_pool.put_back(session)
+
+
+def query_data():
+    # Get a session from the pool
+    session = session_pool.get_session()
+
+    print("get data from table0")
+    res = session.execute_query_statement("select * from table0")
+    while res.has_next():
+        print(res.next())
+
+    print("get data from table1")
+    res = session.execute_query_statement("select * from table0")
+    while res.has_next():
+        print(res.next())
+
+    session_pool.put_back(session)
+
+
+def delete_data():
+    session = session_pool.get_session()
+    session.execute_non_query_statement("drop database db1")
+    print("data has been deleted. now the devices are:")
+    res = session.execute_statement("show databases")
+    while res.has_next():
+        print(res.next())
+    session_pool.put_back(session)
+
+
+ip = "127.0.0.1"
+port = "6667"
+username = "root"
+password = "root"
+pool_config = PoolConfig(
+    node_urls=["127.0.0.1:6667", "127.0.0.1:6668", "127.0.0.1:6669"],
+    user_name=username,
+    password=password,
+    fetch_size=1024,
+    time_zone="UTC+8",
+    max_retry=3,
+    sql_dialect="table",
+    database="db1",
+)
+max_pool_size = 5
+wait_timeout_in_ms = 3000
+
+# Create a session pool
+session_pool = SessionPool(pool_config, max_pool_size, wait_timeout_in_ms)

Review Comment:
   Don’t know +1. @ycycse do you have any idea?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Py-Client] Support table model with python client [iotdb]

Posted by "HTHou (via GitHub)" <gi...@apache.org>.
HTHou commented on code in PR #13443:
URL: https://github.com/apache/iotdb/pull/13443#discussion_r1751217343


##########
iotdb-client/client-py/TableModelSessionPoolExample.py:
##########
@@ -0,0 +1,160 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+import threading
+
+import numpy as np
+
+from iotdb.SessionPool import PoolConfig, SessionPool
+from iotdb.utils.IoTDBConstants import TSDataType
+from iotdb.utils.NumpyTablet import NumpyTablet
+from iotdb.utils.Tablet import ColumnType, Tablet
+
+
+def prepare_data():
+    print("create database")
+    # Get a session from the pool
+    session = session_pool.get_session()
+    session.execute_non_query_statement("CREATE DATABASE IF NOT EXISTS db1")
+    session.execute_non_query_statement('USE "db1"')
+    session.execute_non_query_statement(
+        "CREATE TABLE table0 (id1 string id, attr1 string attribute, "
+        + "m1 double "
+        + "measurement)"
+    )
+    session.execute_non_query_statement(
+        "CREATE TABLE table1 (id1 string id, attr1 string attribute, "
+        + "m1 double "
+        + "measurement)"
+    )
+
+    print("now the tables are:")
+    # show result
+    res = session.execute_query_statement("SHOW TABLES")
+    while res.has_next():
+        print(res.next())
+
+    session_pool.put_back(session)
+
+
+def insert_data(num: int):
+    print("insert data for table" + str(num))
+    # Get a session from the pool
+    session = session_pool.get_session()
+    column_names = [
+        "id1",
+        "attr1",
+        "m1",
+    ]
+    data_types = [
+        TSDataType.STRING,
+        TSDataType.STRING,
+        TSDataType.DOUBLE,
+    ]
+    column_types = [ColumnType.ID, ColumnType.ATTRIBUTE, ColumnType.MEASUREMENT]
+    timestamps = []
+    values = []
+    for row in range(15):
+        timestamps.append(row)
+        values.append(["id:" + str(row), "attr:" + str(row), row * 1.0])
+    tablet = Tablet(
+        "table" + str(num), column_names, data_types, values, timestamps, column_types
+    )
+    session.insert_relational_tablet(tablet)
+    session.execute_non_query_statement("FLush")
+
+    np_timestamps = np.arange(15, 30, dtype=np.dtype(">i8"))
+    np_values = [
+        np.array(["id:{}".format(i) for i in range(15, 30)]),
+        np.array(["attr:{}".format(i) for i in range(15, 30)]),
+        np.linspace(15.0, 29.0, num=15, dtype=TSDataType.DOUBLE.np_dtype()),
+    ]
+
+    np_tablet = NumpyTablet(
+        "table" + str(num),
+        column_names,
+        data_types,
+        np_values,
+        np_timestamps,
+        column_types=column_types,
+    )
+    session.insert_relational_tablet(np_tablet)
+    session_pool.put_back(session)
+
+
+def query_data():
+    # Get a session from the pool
+    session = session_pool.get_session()
+
+    print("get data from table0")
+    res = session.execute_query_statement("select * from table0")
+    while res.has_next():
+        print(res.next())
+
+    print("get data from table1")
+    res = session.execute_query_statement("select * from table0")
+    while res.has_next():
+        print(res.next())
+
+    session_pool.put_back(session)
+
+
+def delete_data():
+    session = session_pool.get_session()
+    session.execute_non_query_statement("drop database db1")
+    print("data has been deleted. now the devices are:")
+    res = session.execute_statement("show databases")

Review Comment:
   fixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Py-Client] Support table model with python client [iotdb]

Posted by "HTHou (via GitHub)" <gi...@apache.org>.
HTHou commented on code in PR #13443:
URL: https://github.com/apache/iotdb/pull/13443#discussion_r1751143017


##########
iotdb-client/client-py/iotdb/utils/Field.py:
##########
@@ -38,13 +38,19 @@ def copy(field):
                 output.set_bool_value(field.get_bool_value())
             elif output.get_data_type() == TSDataType.INT32:
                 output.set_int_value(field.get_int_value())
-            elif output.get_data_type() == TSDataType.INT64:
+            elif (
+                output.get_data_type() == TSDataType.INT64
+                or output.get_data_type() == TSDataType.TIMESTAMP
+            ):
                 output.set_long_value(field.get_long_value())
             elif output.get_data_type() == TSDataType.FLOAT:
                 output.set_float_value(field.get_float_value())
             elif output.get_data_type() == TSDataType.DOUBLE:
                 output.set_double_value(field.get_double_value())
-            elif output.get_data_type() == TSDataType.TEXT:
+            elif (
+                output.get_data_type() == TSDataType.TEXT
+                or output.get_data_type() == TSDataType.STRING
+            ):
                 output.set_binary_value(field.get_binary_value())
             else:

Review Comment:
   This pr is focus on the table model, I think we need another pr to completely support the new data types.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Py-Client] Support table model with python client [iotdb]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #13443:
URL: https://github.com/apache/iotdb/pull/13443#issuecomment-2339570861

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Pyclient] support table model [iotdb]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #13443:
URL: https://github.com/apache/iotdb/pull/13443#issuecomment-2337086506

   ## [Codecov](https://app.codecov.io/gh/apache/iotdb/pull/13443?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   All modified and coverable lines are covered by tests :white_check_mark:
   > Project coverage is 41.32%. Comparing base [(`2a015fc`)](https://app.codecov.io/gh/apache/iotdb/commit/2a015fc4ed80014ab60a4b4b56831128788d58c1?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`f622da2`)](https://app.codecov.io/gh/apache/iotdb/commit/f622da28929559e10bdc8583b0e261bad9d4cf78?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   > Report is 9 commits behind head on master.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #13443      +/-   ##
   ============================================
   - Coverage     41.35%   41.32%   -0.03%     
     Complexity       71       71              
   ============================================
     Files          3957     3961       +4     
     Lines        244866   245128     +262     
     Branches      29667    29687      +20     
   ============================================
   + Hits         101263   101301      +38     
   - Misses       143603   143827     +224     
   ```
   
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/iotdb/pull/13443?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [PyClient] Support table model with python client [iotdb]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #13443:
URL: https://github.com/apache/iotdb/pull/13443#issuecomment-2337853082

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Pyclient] support table model [iotdb]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #13443:
URL: https://github.com/apache/iotdb/pull/13443#issuecomment-2337046116

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Py-Client] Support table model with python client [iotdb]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #13443:
URL: https://github.com/apache/iotdb/pull/13443#issuecomment-2338128123

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [PyClient] Support table model with python client [iotdb]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #13443:
URL: https://github.com/apache/iotdb/pull/13443#issuecomment-2337751752

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [PyClient] Support table model with python client [iotdb]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #13443:
URL: https://github.com/apache/iotdb/pull/13443#issuecomment-2337881541

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [PyClient] Support table model with python client [iotdb]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #13443:
URL: https://github.com/apache/iotdb/pull/13443#issuecomment-2338106791

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Pyclient] support table model [iotdb]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #13443:
URL: https://github.com/apache/iotdb/pull/13443#issuecomment-2337534728

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Py-Client] Support table model with python client [iotdb]

Posted by "jt2594838 (via GitHub)" <gi...@apache.org>.
jt2594838 merged PR #13443:
URL: https://github.com/apache/iotdb/pull/13443


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Py-Client] Support table model with python client [iotdb]

Posted by "ycycse (via GitHub)" <gi...@apache.org>.
ycycse commented on code in PR #13443:
URL: https://github.com/apache/iotdb/pull/13443#discussion_r1751155496


##########
iotdb-client/client-py/TableModelSessionPoolExample.py:
##########
@@ -0,0 +1,160 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+import threading
+
+import numpy as np
+
+from iotdb.SessionPool import PoolConfig, SessionPool
+from iotdb.utils.IoTDBConstants import TSDataType
+from iotdb.utils.NumpyTablet import NumpyTablet
+from iotdb.utils.Tablet import ColumnType, Tablet
+
+
+def prepare_data():
+    print("create database")
+    # Get a session from the pool
+    session = session_pool.get_session()
+    session.execute_non_query_statement("CREATE DATABASE IF NOT EXISTS db1")
+    session.execute_non_query_statement('USE "db1"')
+    session.execute_non_query_statement(
+        "CREATE TABLE table0 (id1 string id, attr1 string attribute, "
+        + "m1 double "
+        + "measurement)"
+    )
+    session.execute_non_query_statement(
+        "CREATE TABLE table1 (id1 string id, attr1 string attribute, "
+        + "m1 double "
+        + "measurement)"
+    )
+
+    print("now the tables are:")
+    # show result
+    res = session.execute_query_statement("SHOW TABLES")
+    while res.has_next():
+        print(res.next())
+
+    session_pool.put_back(session)
+
+
+def insert_data(num: int):
+    print("insert data for table" + str(num))
+    # Get a session from the pool
+    session = session_pool.get_session()
+    column_names = [
+        "id1",
+        "attr1",
+        "m1",
+    ]
+    data_types = [
+        TSDataType.STRING,
+        TSDataType.STRING,
+        TSDataType.DOUBLE,
+    ]
+    column_types = [ColumnType.ID, ColumnType.ATTRIBUTE, ColumnType.MEASUREMENT]
+    timestamps = []
+    values = []
+    for row in range(15):
+        timestamps.append(row)
+        values.append(["id:" + str(row), "attr:" + str(row), row * 1.0])
+    tablet = Tablet(
+        "table" + str(num), column_names, data_types, values, timestamps, column_types
+    )
+    session.insert_relational_tablet(tablet)
+    session.execute_non_query_statement("FLush")
+
+    np_timestamps = np.arange(15, 30, dtype=np.dtype(">i8"))
+    np_values = [
+        np.array(["id:{}".format(i) for i in range(15, 30)]),
+        np.array(["attr:{}".format(i) for i in range(15, 30)]),
+        np.linspace(15.0, 29.0, num=15, dtype=TSDataType.DOUBLE.np_dtype()),
+    ]
+
+    np_tablet = NumpyTablet(
+        "table" + str(num),
+        column_names,
+        data_types,
+        np_values,
+        np_timestamps,
+        column_types=column_types,
+    )
+    session.insert_relational_tablet(np_tablet)
+    session_pool.put_back(session)
+
+
+def query_data():
+    # Get a session from the pool
+    session = session_pool.get_session()
+
+    print("get data from table0")
+    res = session.execute_query_statement("select * from table0")
+    while res.has_next():
+        print(res.next())
+
+    print("get data from table1")
+    res = session.execute_query_statement("select * from table0")
+    while res.has_next():
+        print(res.next())
+
+    session_pool.put_back(session)
+
+
+def delete_data():
+    session = session_pool.get_session()
+    session.execute_non_query_statement("drop database db1")
+    print("data has been deleted. now the devices are:")
+    res = session.execute_statement("show databases")
+    while res.has_next():
+        print(res.next())
+    session_pool.put_back(session)
+
+
+ip = "127.0.0.1"
+port = "6667"
+username = "root"
+password = "root"
+pool_config = PoolConfig(
+    node_urls=["127.0.0.1:6667", "127.0.0.1:6668", "127.0.0.1:6669"],
+    user_name=username,
+    password=password,
+    fetch_size=1024,
+    time_zone="UTC+8",
+    max_retry=3,
+    sql_dialect="table",
+    database="db1",
+)
+max_pool_size = 5
+wait_timeout_in_ms = 3000
+
+# Create a session pool
+session_pool = SessionPool(pool_config, max_pool_size, wait_timeout_in_ms)

Review Comment:
   > Don’t know +1. @ycycse do you have any idea?
   
   Configs in `pool_config` is used to construct and connect session which contains relating infos about session. I think change it to `session_config` would be more clear. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [PyClient] Support table model with python client [iotdb]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #13443:
URL: https://github.com/apache/iotdb/pull/13443#issuecomment-2337817546

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [PyClient] Support table model with python client [iotdb]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #13443:
URL: https://github.com/apache/iotdb/pull/13443#issuecomment-2337782783

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [PyClient] Support table model with python client [iotdb]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #13443:
URL: https://github.com/apache/iotdb/pull/13443#issuecomment-2338018380

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=13443&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_iotdb&pullRequest=13443&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=13443&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=13443)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org