Uh oh!
There was an error while loading. Please reload this page.
[SPARK-58086][SQL][DOCS] Document accepted input and return types in the Scala functions API - #57184
[SPARK-58086][SQL][DOCS] Document accepted input and return types in the Scala functions API#57184HyukjinKwon wants to merge 7 commits into
Conversation
dongjoon-hyun
left a comment
There was a problem hiding this comment.
Could you make the CI happy?
The scalafmt check failed on sql/connect or sql/connect at following occurrences:
org.apache.maven.plugin.MojoExecutionException: Scalafmt: Unformatted files found
Error: Failed to execute goal org.antipathy:mvn-scalafmt_2.13:1.1.1713302731.c3d0074:format (default-cli) on project spark-sql-api_2.13: Error formatting Scala files: Scalafmt: Unformatted files found -> [Help 1]
Before submitting your change, please make sure to format your code using the following command:
./build/mvn scalafmt:format -Dscalafmt.skip=false -Dscalafmt.validateOnly=false -Dscalafmt.changedOnly=false -pl sql/api -pl sql/connect/common -pl sql/connect/server -pl sql/connect/shims -pl sql/connect/client/jvm
f9b4f14 to
88a7746Compare
MaxGekk
left a comment
There was a problem hiding this comment.
0 blocking, 3 non-blocking, 0 nits.
A careful, high-quality documentation pass — the type conventions hold up across the functions I sampled. One @return overstates its type; two smaller doc gaps.
Correctness (1)
- functions.scala:13749:
from_jsonnon-StructTypeoverloads are documented as returning a struct, but they also accept array/map schemas (verified: they returnArrayType/MapType) — see inline
Suggestions (1)
- functions.scala:13628:
posexplode/posexplode_outerhave a@parambut no@return, unlikeexplode/explode_outer— see inline
Nits (1)
- functions.scala:8619: comma splice + "of string" → "of strings" in the
search@param(pre-existing, but on a line this PR edits) — see inline
Verification
Confirmed finding #1 by running from_json against a local build: from_json(col, ArrayType(IntegerType)) → ArrayType(IntegerType,true), from_json(col, MapType(StringType,IntegerType)) → MapType(...), and from_json(col, lit("array<int>")) (Column overload) → ArrayType(...) — none a struct — while the StructType overload correctly returns a struct. Spot-checked seven other @returns (size→integer, array_contains→boolean, ceil→long, concat_ws→string, sqrt→double, abs→same-as-input, map_keys→array); all matched the docs.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
cloud-fan
left a comment
There was a problem hiding this comment.
0 blocking, 0 non-blocking, 0 nits.
No blocking, non-blocking, or nit findings on the current head.
Verification
Mechanically examined 5,267 added documentation lines for objective prose defects and 2,302 structured type-contract candidates across 1,706 claim blocks. The selected scanners reported complete coverage with no findings; the previously reported documentation issues are corrected on the current head.
…the Scala functions API ### What changes were proposed in this pull request? This documents, for every built-in function in the Scala `functions` API (`functions.scala`), the accepted input type of each argument (`@param`) and the return type of each DataFrame function (`@return`), using the numeric umbrella where numeric subtypes cast in and `timestamp` for TIMESTAMP_NTZ in type phrases. Subtask of SPARK-57999, split out from apache#57079 for reviewability. This PR covers only the Scala `functions.scala` surface. ### Why are the changes needed? The Scala `functions` Scaladoc previously had no per-argument type information and no documented return type for most functions. This fills that gap. ### Does this PR introduce _any_ user-facing change? Yes, documentation only. No behavioral or API change. ### How was this patch tested? Scala style/format (scalastyle + scalafmt) and the docs build pass. Types were derived from and verified against the analyzer's behavior and each expression's `inputTypes` / `dataType`. Co-authored-by: Isaac
…@return, replace grammar, nanvl/kll/to_char types, and scalafmt Co-authored-by: Isaac
Match the SQL and PySpark function reference by noting that the variadic concat_ws argument accepts a string or an array of strings. Co-authored-by: Isaac
7b57f59 to
fb39c06CompareAudit surfaced many functions where some arguments (or the return) carried an accepted-type phrase but sibling value arguments did not. Document the missing arguments to match the per-argument coverage promised by the PR, using sibling overloads and the analogous functions as the source of the accepted types. Co-authored-by: Isaac
Cover the accepted types for arguments that were still missing a type phrase in the current_time, radians, hll_sketch_estimate, hll_union, theta_union, and tuple_sketch_agg_* functions, matching their sibling overloads. Co-authored-by: Isaac
…APIs Complete per-argument type coverage for the from_json/to_json/schema_of_json, variant_*, from_csv/to_csv/schema_of_csv, from_xml/to_xml/schema_of_xml, and mask function families, whose returns were documented but whose arguments still lacked accepted-type phrases. Column arguments are documented as evaluating to the accepted type; literal schema/options/path/target-type arguments are noted as constants. Co-authored-by: Isaac
Reflow the added accepted-type doc phrases with scalafmt and add missing terminal punctuation so the merged scaladoc reads correctly. Formatting only. Co-authored-by: Isaac
…he Scala functions API This documents, for every built-in function in the Scala `functions` API (`functions.scala`), the accepted input type of each argument (`param`) and the return type of each DataFrame function (`return`), using the numeric umbrella where numeric subtypes cast in and `timestamp` for TIMESTAMP_NTZ in type phrases. Subtask of SPARK-57999, split out from #57079 for reviewability. This PR covers only the Scala `functions.scala` surface. The Scala `functions` Scaladoc previously had no per-argument type information and no documented return type for most functions. This fills that gap. Yes, documentation only. No behavioral or API change. Scala style/format (scalastyle + scalafmt) and the docs build pass. Types were derived from and verified against the analyzer's behavior and each expression's `inputTypes` / `dataType`. Co-authored-by: Isaac Closes#57184 from HyukjinKwon/split-func-types-scala. Authored-by: Hyukjin Kwon <gurwls223@apache.org> Signed-off-by: Hyukjin Kwon <hyukjin.kwon@databricks.com> (cherry picked from commit 99025ce) Signed-off-by: Hyukjin Kwon <hyukjin.kwon@databricks.com>
What changes were proposed in this pull request?
This documents, for every built-in function in the Scala
functionsAPI (functions.scala), theaccepted input type of each argument (
@param) and the return type of each DataFrame function(
@return), using the numeric umbrella where numeric subtypes cast in andtimestampforTIMESTAMP_NTZ in type phrases.
Subtask of SPARK-57999, split out from #57079 for reviewability. This PR covers only
the Scala
functions.scalasurface.Why are the changes needed?
The Scala
functionsScaladoc previously had no per-argument type information and no documentedreturn type for most functions. This fills that gap.
Does this PR introduce any user-facing change?
Yes, documentation only. No behavioral or API change.
How was this patch tested?
Scala style/format (scalastyle + scalafmt) and the docs build pass. Types were derived from and
verified against the analyzer's behavior and each expression's
inputTypes/dataType.Co-authored-by: Isaac