gengliangwang commented on code in PR #59520:
URL: https://github.com/apache/spark/pull/59520#discussion_r4516812905


##########
examples/src/main/rust/native-data-source/package.py:
##########
@@ -0,0 +1,71 @@
+#!/usr/bin/env python3
+# 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.
+
+"""Package a compiled connector for the native data source C ABI of Spark."""
+
+import argparse
+import json
+from pathlib import Path

Review Comment:
   Done in e6dfbb81b67c: Moved `from pathlib import Path` after the plain 
`import` lines so ruff's isort rule (I001) passes.



##########
examples/src/main/rust/native-data-source/smoke.py:
##########
@@ -0,0 +1,130 @@
+#!/usr/bin/env python3
+# 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.
+
+"""Run with Java 22+ and spark-submit from a distribution with native data 
sources (4.4.0+)."""
+
+import argparse
+from pathlib import Path

Review Comment:
   Done in e6dfbb81b67c: Moved `from pathlib import Path` after `import 
tempfile`, and split the import into `from pyspark.sql import SparkSession` and 
`from pyspark.sql import functions as F`.



##########
examples/src/main/rust/native-data-sink/smoke.py:
##########
@@ -0,0 +1,161 @@
+#!/usr/bin/env python3
+# 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.
+
+"""Run with Java 22+ and local spark-submit from a build with native data 
sources (4.4.0+)."""
+
+import argparse
+import json
+from pathlib import Path

Review Comment:
   Done in e6dfbb81b67c: Moved `from pathlib import Path` after `import 
tempfile`.



##########
examples/src/main/rust/native-data-source/tests/c_abi_smoke.rs:
##########
@@ -0,0 +1,88 @@
+// 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.
+
+#![cfg(any(target_os = "linux", target_os = "macos"))]
+
+use std::error::Error;
+use std::fs;
+use std::path::{Path, PathBuf};
+use std::process::Command;
+use std::time::{SystemTime, UNIX_EPOCH};
+
+struct TestDirectory(PathBuf);
+
+impl Drop for TestDirectory {
+    fn drop(&mut self) {
+        let _ = fs::remove_dir_all(&self.0);
+    }
+}
+
+#[test]
+fn c_abi_arrow_round_trip() -> Result<(), Box<dyn Error>> {
+    let unique = SystemTime::now().duration_since(UNIX_EPOCH)?.as_nanos();
+    let directory = TestDirectory(
+        std::env::temp_dir().join(format!("spark-native-c-{}-{unique}", 
std::process::id())),
+    );
+    fs::create_dir(&directory.0)?;
+
+    let manifest = Path::new(env!("CARGO_MANIFEST_DIR"));
+    // The header of the Spark source tree, as a library would copy it.
+    let header =
+        
manifest.join("../../../../../sql/core/src/main/resources/org/apache/spark/sql/datasource");
+    let harness = directory.0.join("c_abi_smoke");
+    let compiler = std::env::var_os("CC").unwrap_or_else(|| "cc".into());

Review Comment:
   Done in e6dfbb81b67c: The harness now splits `CC` on whitespace. It runs the 
first word as the program and passes the remaining words before its own flags. 
It still defaults to `cc`.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to