piyushka-ally opened a new pull request, #177:
URL: https://github.com/apache/spark-connect-go/pull/177
What changes were proposed in this pull request?
This PR adds the Dtypes method to the DataFrame interface and its
implementation on dataFrameImpl in the Go Spark Connect client. The method
returns column names paired with their data type strings as [][2]string,
mirroring PySpark's DataFrame.dtypes property.
The implementation reuses the existing Schema() method and follows the same
pattern as the already-implemented Columns() method
(spark/sql/dataframe.go:303), additionally extracting field.DataType.TypeName()
for each field.
This is tracked in the umbrella issue:
https://github.com/apache/spark-connect-go/issues/58
Why are the changes needed?
dtypes is a standard DataFrame API in PySpark that returns the list of
column names and their data types. It is listed as unimplemented in the
DataFrame functionality tracking issue. Adding it improves API parity between
the Go Spark Connect client and PySpark, making it easier for users to inspect
the schema of a DataFrame in a concise format.
Does this PR introduce any user-facing change?
Yes. A new method Dtypes(ctx context.Context) ([][2]string, error) is added
to the public DataFrame interface. Users can now call Dtypes on a DataFrame to
get column name and type pairs, for example:
dtypes, err := df.Dtypes(ctx)
// dtypes: [["age", "Integer"], ["name", "String"]]
There is no change to existing behavior.
How was this patch tested?
The implementation is a straightforward extension of the existing Columns()
method pattern; it calls Schema() and iterates over the fields. No new unit
tests were added because Dtypes depends on Schema() which requires a live Spark
session (same as Columns()). The method can be verified via integration tests
against a running Spark Connect server.
--
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]