luoyuxia commented on code in PR #151:
URL: https://github.com/apache/fluss-rust/pull/151#discussion_r2694994437


##########
bindings/python/src/table.rs:
##########
@@ -57,32 +63,64 @@ impl FlussTable {
         })
     }
 
-    /// Create a new log scanner for the table
-    fn new_log_scanner<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, 
PyAny>> {
-        let conn = self.connection.clone();
-        let metadata = self.metadata.clone();
-        let table_info = self.table_info.clone();
-
-        future_into_py(py, async move {
-            let fluss_table =
-                fcore::client::FlussTable::new(&conn, metadata.clone(), 
table_info.clone());
-
-            let table_scan = fluss_table.new_scan();
-
-            let rust_scanner = table_scan.create_log_scanner().map_err(|e| {
-                PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(format!(
-                    "Failed to create log scanner: {e:?}"
-                ))
-            })?;
-
-            let admin = conn
-                .get_admin()
-                .await
-                .map_err(|e| FlussError::new_err(e.to_string()))?;
+    /// Create a new log scanner for the table.
+    ///
+    /// Args:
+    ///     project: Optional list of column indices (0-based) to include in 
the scan.
+    ///              Empty list means all columns.
+    ///     columns: Optional list of column names to include in the scan.
+    ///              Empty list means all columns.
+    ///
+    /// Returns:
+    ///     LogScanner, optionally with projection applied
+    ///
+    /// Note:
+    ///     Specify only one of 'project' or 'columns'.
+    ///     If neither is specified, all columns are included.
+    ///
+    /// Examples:
+    ///     >>> # Scan all columns
+    ///     >>> scanner = await table.new_log_scanner()
+    ///
+    ///     >>> # Scan specific columns by index
+    ///     >>> scanner = await table.new_log_scanner(project=[0, 2, 4])
+    ///
+    ///     >>> # Scan specific columns by name (more Pythonic)
+    ///     >>> scanner = await table.new_log_scanner(columns=["id", "name", 
"email"])
+    #[pyo3(signature = (project=None, columns=None))]
+    pub fn new_log_scanner<'py>(
+        &self,
+        py: Python<'py>,
+        project: Option<Vec<usize>>,
+        columns: Option<Vec<String>>,
+    ) -> PyResult<Bound<'py, PyAny>> {
+        // Validate mutually exclusive parameters and normalize empty lists
+        let projection = match (project, columns) {
+            (Some(_), Some(_)) => {
+                return Err(FlussError::new_err(
+                    "Specify only one of 'project' or 'columns'".to_string(),
+                ));
+            }
+            (Some(indices), None) => {
+                if indices.is_empty() {

Review Comment:
   can we just rutrn error when indices is emtpy? This behavior align with 
rust-core and java side.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to