This is an automated email from the ASF dual-hosted git repository.
HyukjinKwon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark-connect-rust.git
The following commit(s) were added to refs/heads/master by this push:
new 9e2af710 [SPARK-61249][CONNECT][PYTHON][TESTS][FOLLOWUP] Turn on the
nanosecond timestamp types in the live test that collects them, so that it runs
against a server without SPARK_TESTING
9e2af710 is described below
commit 9e2af7106f05807969aa3b6063b2f34c276cd3f7
Author: Hyukjin Kwon <[email protected]>
AuthorDate: Mon Nov 9 22:24:02 2026 +0900
[SPARK-61249][CONNECT][PYTHON][TESTS][FOLLOWUP] Turn on the nanosecond
timestamp types in the live test that collects them, so that it runs against a
server without SPARK_TESTING
### What changes were proposed in this pull request?
A follow-up of
[SPARK-61249](https://issues.apache.org/jira/browse/SPARK-61249) (#427):
`test_nanosecond_timestamps_are_not_collected_as_pyspark` in
`python/tests/test_dropin_e2e.py` now turns on
`spark.sql.timestampNanosTypes.enabled` for the session while it runs, and
unsets it afterwards, back to the server's default.
### Why are the changes needed?
The test creates `TIMESTAMP_NTZ(9)` and `TIMESTAMP_LTZ(7)` values, which
need that conf. It is on by default only on a server under `SPARK_TESTING`, as
CI's servers are, so the test passed in CI but failed against a server started
without it: the SQL itself raised `[FEATURE_NOT_ENABLED] The feature
Nanosecond-precision timestamp types is not enabled`.
### Does this PR introduce _any_ user-facing change?
No, test only.
### How was this patch tested?
- The test, and the other `-k "nanosecond or ntz or timestamp"` live tests
(7 passed), against a local Spark 4.3.0 server started without `SPARK_TESTING`
(it failed there before this change with `FEATURE_NOT_ENABLED`) and against one
under `SPARK_TESTING`; also under pytest 9.2.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 5.5
This pull request and its description were written by Isaac.
Closes #429 from HyukjinKwon/SPARK-61249-followup-nanos-conf.
Authored-by: Hyukjin Kwon <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
---
python/tests/test_dropin_e2e.py | 51 +++++++++++++++++++++++------------------
1 file changed, 29 insertions(+), 22 deletions(-)
diff --git a/python/tests/test_dropin_e2e.py b/python/tests/test_dropin_e2e.py
index 2dbb346c..35cddcfb 100644
--- a/python/tests/test_dropin_e2e.py
+++ b/python/tests/test_dropin_e2e.py
@@ -504,28 +504,35 @@ def
test_nanosecond_timestamps_are_not_collected_as_pyspark(session):
("SELECT array(CAST('2020-01-01 00:00:00.123456789' AS
TIMESTAMP_LTZ(9))) c", ltz9),
("SELECT map('k', CAST('2020-01-01 00:00:00.123456789' AS
TIMESTAMP_NTZ(9))) c", ntz9),
]
- for query, proto_text in cases:
- df = session.sql(query)
- for collect in (
- lambda d: d.collect(),
- lambda d: d.first(),
- lambda d: d.head(),
- lambda d: d.head(1),
- lambda d: d.take(1),
- lambda d: d.tail(1),
- lambda d: list(d.toLocalIterator()),
- lambda d: d.toPandas(),
- lambda d: d.toArrow(),
- ):
- with pytest.raises(PySparkValueError, match=message(proto_text)):
- collect(df)
- # Spark Connect and PySpark both count and show these results.
- df = session.sql("SELECT CAST('2020-01-01 00:00:00.123456789' AS
TIMESTAMP_NTZ(9)) c")
- assert df.count() == 1
- df.show()
- # Microsecond timestamps still collect.
- micros = session.sql("SELECT CAST('2020-01-01 00:00:00.123456' AS
TIMESTAMP_NTZ(6)) c")
- assert micros.collect()[0].c == datetime.datetime(2020, 1, 1, 0, 0, 0,
123456)
+ # The types need spark.sql.timestampNanosTypes.enabled, which is on by
default only on a
+ # server under SPARK_TESTING, as CI's servers are: turn it on, and back to
the server's
+ # default after, so that the test runs against any server.
+ session.conf.set("spark.sql.timestampNanosTypes.enabled", "true")
+ try:
+ for query, proto_text in cases:
+ df = session.sql(query)
+ for collect in (
+ lambda d: d.collect(),
+ lambda d: d.first(),
+ lambda d: d.head(),
+ lambda d: d.head(1),
+ lambda d: d.take(1),
+ lambda d: d.tail(1),
+ lambda d: list(d.toLocalIterator()),
+ lambda d: d.toPandas(),
+ lambda d: d.toArrow(),
+ ):
+ with pytest.raises(PySparkValueError,
match=message(proto_text)):
+ collect(df)
+ # Spark Connect and PySpark both count and show these results.
+ df = session.sql("SELECT CAST('2020-01-01 00:00:00.123456789' AS
TIMESTAMP_NTZ(9)) c")
+ assert df.count() == 1
+ df.show()
+ # Microsecond timestamps still collect.
+ micros = session.sql("SELECT CAST('2020-01-01 00:00:00.123456' AS
TIMESTAMP_NTZ(6)) c")
+ assert micros.collect()[0].c == datetime.datetime(2020, 1, 1, 0, 0, 0,
123456)
+ finally:
+ session.conf.unset("spark.sql.timestampNanosTypes.enabled")
def test_ntz_collect_is_the_wall_clock_in_the_client_time_zone_as_pyspark():
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]