Copilot commented on code in PR #1729:
URL: 
https://github.com/apache/datafusion-python/pull/1729#discussion_r3990300759


##########
examples/csv-read-options.py:
##########
@@ -17,80 +17,101 @@
 
 """Example demonstrating CsvReadOptions usage."""
 
+import gzip
+import tempfile
+from pathlib import Path
+
 from datafusion import CsvReadOptions, SessionContext
 
-# Create a SessionContext
-ctx = SessionContext()
+# Create sample data files in a temporary directory to make the example 
self-contained
+with tempfile.TemporaryDirectory() as tmp_dir:
+    tmp_path = Path(tmp_dir)
+    csv_file = tmp_path / "data.csv"
+    gz_file = tmp_path / "data.csv.gz"
+
+    sample_csv = "id,name,value\n1,alice,100\n2,bob,200\n3,charlie,null\n"
+    csv_file.write_text(sample_csv)
+
+    with gzip.open(gz_file, "wt") as f:
+        f.write(sample_csv)
+
+    # Create a SessionContext
+    ctx = SessionContext()
 
-# Example 1: Using CsvReadOptions with default values
-print("Example 1: Default CsvReadOptions")
-options = CsvReadOptions()
-df = ctx.read_csv("data.csv", options=options)
+    # Example 1: Using CsvReadOptions with default values
+    print("Example 1: Default CsvReadOptions")
+    options = CsvReadOptions()
+    df = ctx.read_csv(str(csv_file), options=options)
+    df.show()
 
-# Example 2: Using CsvReadOptions with custom parameters
-print("\nExample 2: Custom CsvReadOptions")
-options = CsvReadOptions(
-    has_header=True,
-    delimiter=",",
-    quote='"',
-    schema_infer_max_records=1000,
-    file_extension=".csv",
-)
-df = ctx.read_csv("data.csv", options=options)
+    # Example 2: Using CsvReadOptions with custom parameters
+    print("\nExample 2: Custom CsvReadOptions")
+    options = CsvReadOptions(
+        has_header=True,
+        delimiter=",",
+        quote='"',
+        schema_infer_max_records=1000,
+        file_extension=".csv",
+    )
+    df = ctx.read_csv(str(csv_file), options=options)
+    df.show()
 
-# Example 3: Using the builder pattern (recommended for readability)
-print("\nExample 3: Builder pattern")
-options = (
-    CsvReadOptions()
-    .with_has_header(True)  # noqa: FBT003
-    .with_delimiter("|")
-    .with_quote("'")
-    .with_schema_infer_max_records(500)
-    .with_truncated_rows(False)  # noqa: FBT003
-    .with_newlines_in_values(True)  # noqa: FBT003
-)
-df = ctx.read_csv("data.csv", options=options)
+    # Example 3: Using the builder pattern (recommended for readability)
+    print("\nExample 3: Builder pattern")
+    options = (
+        CsvReadOptions()
+        .with_has_header(True)  # noqa: FBT003
+        .with_delimiter("|")
+        .with_quote("'")
+        .with_schema_infer_max_records(500)
+        .with_truncated_rows(False)  # noqa: FBT003
+        .with_newlines_in_values(True)  # noqa: FBT003
+    )
+    df = ctx.read_csv(str(csv_file), options=options)

Review Comment:
   This DataFrame is never executed, so Example 3 produces no output and does 
not validate that the builder options can read the generated file. Add a 
terminal call here, such as `df.show()`, as with the other examples.



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