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 /python/pyspark | |
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 'python/pyspark')
-rw-r--r-- | python/pyspark/sql/dataframe.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/python/pyspark/sql/dataframe.py b/python/pyspark/sql/dataframe.py index a986092f5d..e5eac918a9 100644 --- a/python/pyspark/sql/dataframe.py +++ b/python/pyspark/sql/dataframe.py @@ -644,7 +644,7 @@ class DataFrame(object): on = [on] if on is None or len(on) == 0: - jdf = self._jdf.join(other._jdf) + jdf = self._jdf.crossJoin(other._jdf) elif isinstance(on[0], basestring): if how is None: jdf = self._jdf.join(other._jdf, self._jseq(on), "inner") |