diff options
author | Srinath Shankar <srinath@databricks.com> | 2016-09-03 00:20:43 +0200 |
---|---|---|
committer | Herman van Hovell <hvanhovell@databricks.com> | 2016-09-03 00:20:43 +0200 |
commit | e6132a6cf10df8b12af8dd8d1a2c563792b5cc5a (patch) | |
tree | d706ac4d4091a7ae31eda5c7d62c2d8c2c4a7414 /R/pkg | |
parent | a2c9acb0e54b2e38cb8ee6431f1ea0e0b4cd959a (diff) | |
download | spark-e6132a6cf10df8b12af8dd8d1a2c563792b5cc5a.tar.gz spark-e6132a6cf10df8b12af8dd8d1a2c563792b5cc5a.tar.bz2 spark-e6132a6cf10df8b12af8dd8d1a2c563792b5cc5a.zip |
[SPARK-17298][SQL] Require explicit CROSS join for cartesian products
## What changes were proposed in this pull request?
Require the use of CROSS join syntax in SQL (and a new crossJoin
DataFrame API) to specify explicit cartesian products between relations.
By cartesian product we mean a join between relations R and S where
there is no join condition involving columns from both R and S.
If a cartesian product is detected in the absence of an explicit CROSS
join, an error must be thrown. Turning on the
"spark.sql.crossJoin.enabled" configuration flag will disable this check
and allow cartesian products without an explicit CROSS join.
The new crossJoin DataFrame API must be used to specify explicit cross
joins. The existing join(DataFrame) method will produce a INNER join
that will require a subsequent join condition.
That is df1.join(df2) is equivalent to select * from df1, df2.
## How was this patch tested?
Added cross-join.sql to the SQLQueryTestSuite to test the check for cartesian products. Added a couple of tests to the DataFrameJoinSuite to test the crossJoin API. Modified various other test suites to explicitly specify a cross join where an INNER join or a comma-separated list was previously used.
Author: Srinath Shankar <srinath@databricks.com>
Closes #14866 from srinathshankar/crossjoin.
Diffstat (limited to 'R/pkg')
-rw-r--r-- | R/pkg/R/DataFrame.R | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/R/pkg/R/DataFrame.R b/R/pkg/R/DataFrame.R index a92450274e..d7686972d2 100644 --- a/R/pkg/R/DataFrame.R +++ b/R/pkg/R/DataFrame.R @@ -2276,7 +2276,7 @@ setMethod("join", signature(x = "SparkDataFrame", y = "SparkDataFrame"), function(x, y, joinExpr = NULL, joinType = NULL) { if (is.null(joinExpr)) { - sdf <- callJMethod(x@sdf, "join", y@sdf) + sdf <- callJMethod(x@sdf, "crossJoin", y@sdf) } else { if (class(joinExpr) != "Column") stop("joinExpr must be a Column") if (is.null(joinType)) { |