This is an automated email from the ASF dual-hosted git repository.

jackietien pushed a commit to branch ty/pythonClient
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/ty/pythonClient by this push:
     new 909e3362fb0 change according to code review
909e3362fb0 is described below

commit 909e3362fb06bb1403a76c5e8bdefc0cf4366275
Author: JackieTien97 <[email protected]>
AuthorDate: Sun Jan 18 13:46:17 2026 +0800

    change according to code review
---
 iotdb-client/client-py/iotdb/utils/SessionDataSet.py    |  7 +++----
 iotdb-client/client-py/iotdb/utils/iotdb_rpc_dataset.py | 11 ++++++++++-
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/iotdb-client/client-py/iotdb/utils/SessionDataSet.py 
b/iotdb-client/client-py/iotdb/utils/SessionDataSet.py
index 67509d3c059..de4ef31dfa1 100644
--- a/iotdb-client/client-py/iotdb/utils/SessionDataSet.py
+++ b/iotdb-client/client-py/iotdb/utils/SessionDataSet.py
@@ -143,17 +143,16 @@ class SessionDataSet(object):
     def close_operation_handle(self):
         self.iotdb_rpc_data_set.close()
 
-    def has_next_df(self):
+    def has_next_df(self) -> bool:
         """
         Evaluate if there are more DataFrames to be fetched.
         :return: whether there are more DataFrames to be fetched
         """
         # Check if buffer has data or if there are more results to fetch
         rpc_ds = self.iotdb_rpc_data_set
-        has_buffer = rpc_ds._IoTDBRpcDataSet__df_buffer is not None and 
len(rpc_ds._IoTDBRpcDataSet__df_buffer) > 0
-        return has_buffer or rpc_ds._has_next_result_set()
+        return rpc_ds._has_buffered_data() or rpc_ds._has_next_result_set()
 
-    def next_df(self):
+    def next_df(self) -> "pd.DataFrame | None":
         """
         Get the next DataFrame from the result set.
         Each returned DataFrame contains exactly fetch_size rows,
diff --git a/iotdb-client/client-py/iotdb/utils/iotdb_rpc_dataset.py 
b/iotdb-client/client-py/iotdb/utils/iotdb_rpc_dataset.py
index 5afa8b152a5..7c3831aca7f 100644
--- a/iotdb-client/client-py/iotdb/utils/iotdb_rpc_dataset.py
+++ b/iotdb-client/client-py/iotdb/utils/iotdb_rpc_dataset.py
@@ -18,6 +18,7 @@
 
 # for package
 import logging
+from typing import Optional
 
 import numpy as np
 import pandas as pd
@@ -125,6 +126,7 @@ class IoTDBRpcDataSet(object):
     def close(self):
         if self.__is_closed:
             return
+        self.__df_buffer = None  # Clean up streaming DataFrame buffer
         if self.__client is not None:
             try:
                 status = self.__client.closeOperation(
@@ -244,7 +246,14 @@ class IoTDBRpcDataSet(object):
             return True
         return False
 
-    def next_dataframe(self):
+    def _has_buffered_data(self) -> bool:
+        """
+        Check if there is buffered data for streaming DataFrame interface.
+        :return: True if there is buffered data, False otherwise
+        """
+        return self.__df_buffer is not None and len(self.__df_buffer) > 0
+
+    def next_dataframe(self) -> Optional[pd.DataFrame]:
         """
         Get the next DataFrame from the result set with exactly fetch_size 
rows.
         The last DataFrame may have fewer rows.

Reply via email to