Skip to content

Conversation

@marmbrus
Copy link
Contributor

An initial version of analysis checks. Long term we are going to want something more complete, but this at least prevents us from making it all the way execution with obvious problems. For example, doing a sort on a misspelled attribute is actually enough to kill the DAG scheduler.

@AmplabJenkins
Copy link

Merged build triggered.

@AmplabJenkins
Copy link

Merged build started.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick sort the import

@AmplabJenkins
Copy link

Merged build finished.

@AmplabJenkins
Copy link

Refer to this link for build results: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/16245/

@rxin
Copy link
Contributor

rxin commented Jun 29, 2014

Maybe also add a test case?

rxin added a commit to rxin/spark that referenced this pull request Jun 30, 2014
[SPARK-2059][SQL] Add analysis checks
@marmbrus marmbrus closed this Jun 30, 2014
asfgit pushed a commit that referenced this pull request Jul 4, 2014
This replaces #1263 with a test case.

Author: Reynold Xin <[email protected]>
Author: Michael Armbrust <[email protected]>

Closes #1265 from rxin/sql-analysis-error and squashes the following commits:

a639e01 [Reynold Xin] Added a test case for unresolved attribute analysis.
7371e1b [Reynold Xin] Merge pull request #1263 from marmbrus/analysisChecks
448c088 [Michael Armbrust] Add analysis checks
asfgit pushed a commit that referenced this pull request Jul 4, 2014
This replaces #1263 with a test case.

Author: Reynold Xin <[email protected]>
Author: Michael Armbrust <[email protected]>

Closes #1265 from rxin/sql-analysis-error and squashes the following commits:

a639e01 [Reynold Xin] Added a test case for unresolved attribute analysis.
7371e1b [Reynold Xin] Merge pull request #1263 from marmbrus/analysisChecks
448c088 [Michael Armbrust] Add analysis checks

(cherry picked from commit b3e768e)
Signed-off-by: Reynold Xin <[email protected]>
asfgit pushed a commit that referenced this pull request Jul 4, 2014
This replaces #1263 with a test case.

Author: Reynold Xin <[email protected]>
Author: Michael Armbrust <[email protected]>

Closes #1265 from rxin/sql-analysis-error and squashes the following commits:

a639e01 [Reynold Xin] Added a test case for unresolved attribute analysis.
7371e1b [Reynold Xin] Merge pull request #1263 from marmbrus/analysisChecks
448c088 [Michael Armbrust] Add analysis checks

(cherry picked from commit b3e768e)
Signed-off-by: Reynold Xin <[email protected]>
@marmbrus marmbrus deleted the analysisChecks branch July 8, 2014 22:49
xiliu82 pushed a commit to xiliu82/spark that referenced this pull request Sep 4, 2014
This replaces apache#1263 with a test case.

Author: Reynold Xin <[email protected]>
Author: Michael Armbrust <[email protected]>

Closes apache#1265 from rxin/sql-analysis-error and squashes the following commits:

a639e01 [Reynold Xin] Added a test case for unresolved attribute analysis.
7371e1b [Reynold Xin] Merge pull request apache#1263 from marmbrus/analysisChecks
448c088 [Michael Armbrust] Add analysis checks
wangyum added a commit that referenced this pull request May 26, 2023
…#1263)

### What changes were proposed in this pull request?

This PR enhance `UnwrapCastInBinaryComparison` to support unwrap timestamp type.

The way to unwrap timestamp type are:
```
GreaterThan(Cast(ts, DateType), date) -> GreaterThanOrEqual(ts, Cast(date + 1, TimestampType))
GreaterThanOrEqual(Cast(ts, DateType), date) -> GreaterThanOrEqual(ts, Cast(date, TimestampType))
LessThan(Cast(ts, DateType), date) -> LessThan(ts, Cast(date, TimestampType))
LessThanOrEqual(Cast(ts, DateType), date) -> LessThan(ts, Cast(date + 1, TimestampType))
EqualTo(Cast(ts, DateType), date) -> And(GreaterThanOrEqual(ts, Cast(date, TimestampType)), LessThan(ts, Cast(date + 1, TimestampType)))
```


### Why are the changes needed?

Improve query performance.

A common use case. We store cold data in HDFS by partition, store hot data in MySQL, and then union all the results. The filter in the MySQL branch cannot be pushed down, which affects performance:
```sql
CREATE TABLE t_cold(id bigint, start timestamp, dt date) using parquet PARTITIONED BY (dt);
CREATE TABLE t_hot(id bigint, start timestamp) using org.apache.spark.sql.jdbc OPTIONS (`url` '***', `dbtable` 'db.t2', `user` 'spark', `password` '***');
CREATE VIEW all_data AS SELECT * FROM t_cold UNION ALL SELECT *, to_date(start) FROM t_hot;
SELECT * FROM all_data WHERE start BETWEEN '2023-02-06' AND '2023-02-07';
```

Before this PR | After this PR
-- | --
<img src="https://user-images.githubusercontent.com/5399861/221576723-7fc45356-65db-48e2-8d40-88420c21c9f5.png" width="400" height="730"> | <img src="https://user-images.githubusercontent.com/5399861/221575848-5b975ed0-70ab-4527-acfe-796cc20e169b.png" width="400" height="730">


### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Unit test.
ashevchuk123 pushed a commit to mapr/spark that referenced this pull request Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants