Skip to content

Review panics in the sql crate - #3397

Merged
alamb merged 2 commits into
apache:masterfrom
HaoYang670:3315_panic_sql_crate
Sep 10, 2022
Merged

Review panics in the sql crate#3397
alamb merged 2 commits into
apache:masterfrom
HaoYang670:3315_panic_sql_crate

Conversation

@HaoYang670

Copy link
Copy Markdown
Contributor

Signed-off-by: remzi 13716567376yh@gmail.com

Which issue does this PR close?

Closes #3315.

Rationale for this change

What changes are included in this PR?

Are there any user-facing changes?

Signed-off-by: remzi <13716567376yh@gmail.com>
@github-actions github-actions Bot added the sql SQL Planner label Sep 8, 2022
Signed-off-by: remzi <13716567376yh@gmail.com>
Comment thread datafusion/sql/src/planner.rs

@andygrove andygrove left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Thanks @HaoYang670

Comment on lines +2686 to 2693
match (n.parse::<i64>(), n.parse::<f64>()) {
(Ok(n), _) => Ok(lit(n)),
(Err(_), Ok(n)) => Ok(lit(n)),
(Err(_), Err(_)) => Err(DataFusionError::from(ParserError(format!(
"Cannot parse {} as i64 or f64",
n
)))),
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It may be simpler to do this in two steps?

Suggested change
match (n.parse::<i64>(), n.parse::<f64>()) {
(Ok(n), _) => Ok(lit(n)),
(Err(_), Ok(n)) => Ok(lit(n)),
(Err(_), Err(_)) => Err(DataFusionError::from(ParserError(format!(
"Cannot parse {} as i64 or f64",
n
)))),
}
match n.parse::<i64>() {
Ok(n) => Ok(lit(n)),
_ => match n.parse::<f64>() {
Ok(n) => Ok(lit(n)),
_ => Err(DataFusionError::from(ParserError(format!("Cannot parse {} as i64 or f64", n)))),
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here is an alternate proposal of (yet) another way to do it: #3432

@alamb

alamb commented Sep 10, 2022

Copy link
Copy Markdown
Contributor

Thank you @HaoYang670

@alamb
alamb merged commit e14d090 into apache:master Sep 10, 2022
@ursabot

ursabot commented Sep 10, 2022

Copy link
Copy Markdown

Benchmark runs are scheduled for baseline = 8b59b20 and contender = e14d090. e14d090 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sql SQL Planner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Review use of panic in datafusion-sql crate

4 participants