Skip to content

[SPARK-25557][SQL] Nested column predicate pushdown for ORC - #28761

Closed
viirya wants to merge 9 commits into
apache:masterfrom
viirya:SPARK-25557
Closed

[SPARK-25557][SQL] Nested column predicate pushdown for ORC#28761
viirya wants to merge 9 commits into
apache:masterfrom
viirya:SPARK-25557

Conversation

@viirya

@viirya viirya commented Jun 9, 2020

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

We added nested column predicate pushdown for Parquet in #27728. This patch extends the feature support to ORC.

Why are the changes needed?

Extending the feature to ORC for feature parity. Better performance for handling nested predicate pushdown.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Unit tests.

@SparkQA

SparkQA commented Jun 9, 2020

Copy link
Copy Markdown

Test build #123660 has finished for PR 28761 at commit 1486382.

  • This patch fails Scala style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA

SparkQA commented Jun 9, 2020

Copy link
Copy Markdown

Test build #123662 has finished for PR 28761 at commit e12939e.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@viirya

viirya commented Jun 9, 2020

Copy link
Copy Markdown
Member Author

@maropu maropu 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.

Basically, looks okay to me.

Comment thread sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala Outdated
@SparkQA

SparkQA commented Jun 10, 2020

Copy link
Copy Markdown

Test build #123727 has finished for PR 28761 at commit bd691ed.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@viirya

viirya commented Jun 10, 2020

Copy link
Copy Markdown
Member Author

retest this please

@SparkQA

SparkQA commented Jun 10, 2020

Copy link
Copy Markdown

Test build #123732 has finished for PR 28761 at commit bd691ed.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@viirya

viirya commented Jun 16, 2020

Copy link
Copy Markdown
Member Author

retest this please

@SparkQA

SparkQA commented Jun 17, 2020

Copy link
Copy Markdown

Test build #124143 has finished for PR 28761 at commit bd691ed.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@maropu

maropu commented Jun 25, 2020

Copy link
Copy Markdown
Member

kindly ping @dbtsai @dongjoon-hyun @cloud-fan

@maropu

maropu commented Jun 25, 2020

Copy link
Copy Markdown
Member

retest this please

@SparkQA

SparkQA commented Jun 25, 2020

Copy link
Copy Markdown

Test build #124506 has finished for PR 28761 at commit bd691ed.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA

SparkQA commented Jun 29, 2020

Copy link
Copy Markdown

Test build #124634 has finished for PR 28761 at commit e76b5f4.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

HyukjinKwon added a commit that referenced this pull request Jul 1, 2020
…potential conflicts in dev

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

This PR proposes to partially reverts back in the tests and some codes at #27728 without touching any behaivours.

Most of changes in tests are back before #27728 by combining `withNestedDataFrame` and `withParquetDataFrame`.

Basically, it addresses the comments #27728 (comment), and my own comment in another PR at #28761 (comment)

### Why are the changes needed?

For maintenance purpose and to avoid a potential conflicts during backports. And also in case when other codes are matched with this.

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

No, dev-only.

### How was this patch tested?

Manually tested.

Closes #28955 from HyukjinKwon/SPARK-25556-followup.

Authored-by: HyukjinKwon <gurwls223@apache.org>
Signed-off-by: HyukjinKwon <gurwls223@apache.org>
HyukjinKwon added a commit that referenced this pull request Jul 1, 2020
…potential conflicts in dev

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

This PR proposes to partially reverts back in the tests and some codes at #27728 without touching any behaivours.

Most of changes in tests are back before #27728 by combining `withNestedDataFrame` and `withParquetDataFrame`.

Basically, it addresses the comments #27728 (comment), and my own comment in another PR at #28761 (comment)

### Why are the changes needed?

For maintenance purpose and to avoid a potential conflicts during backports. And also in case when other codes are matched with this.

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

No, dev-only.

### How was this patch tested?

Manually tested.

Closes #28955 from HyukjinKwon/SPARK-25556-followup.

Authored-by: HyukjinKwon <gurwls223@apache.org>
Signed-off-by: HyukjinKwon <gurwls223@apache.org>
(cherry picked from commit 8194d9e)
Signed-off-by: HyukjinKwon <gurwls223@apache.org>
@viirya

viirya commented Jul 29, 2020

Copy link
Copy Markdown
Member Author

I'll clean up the tests more.

@SparkQA

SparkQA commented Jul 29, 2020

Copy link
Copy Markdown

Test build #126759 has finished for PR 28761 at commit 7175e7c.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@HyukjinKwon

Copy link
Copy Markdown
Member

retest this please

@SparkQA

SparkQA commented Jul 29, 2020

Copy link
Copy Markdown

Test build #126761 has finished for PR 28761 at commit 7175e7c.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

// mode, just skip pushdown for these fields, they will trigger Exception when reading,
// See: SPARK-25175.
val dedupPrimitiveFields =
primitiveFields

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.

indentation?

- val dedupPrimitiveFields =
- primitiveFields
+ val dedupPrimitiveFields = primitiveFields

if (caseSensitive) {
primitiveFields.toMap
} else {
// Don't consider ambiguity here, i.e. more than one field is matched in case insensitive

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.

is matched -> are matched?


/**
* Writes `data` to a Orc file and reads it back as a `DataFrame`,
* Writes `date` dataframe to a Orc file and reads it back as a `DataFrame`,

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.

Is there a reason you change this from data to date? This is not limited to DATE. The original one looks correct to me.

@viirya viirya Aug 6, 2020

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oops, a typo. :) Will correct it.

* dataframes as new test data. It tests both non-nested and nested dataframes
* which are written and read back with Orc datasource.
*
* This is different from [[OrcTest.withOrcDataFrame]] which does not

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.

Do we need OrcTest. prefix?

@dongjoon-hyun dongjoon-hyun changed the title [SPARK-25557][SQL][test-hadoop2.7][test-hive1.2] Nested column predicate pushdown for ORC [SPARK-25557][SQL] Nested column predicate pushdown for ORC Aug 6, 2020
* This method returns a map which contains ORC field name and data type. Each key
* represents a column; `dots` are used as separators for nested columns. If any part
* of the names contains `dots`, it is quoted to avoid confusion. See
* `org.apache.spark.sql.connector.catalog.quote` for implementation details.

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.

quote -> quoted.

case BinaryType => false
case _: AtomicType => true
case _ => false
protected[sql] def getNameToOrcFieldMap(

@dongjoon-hyun dongjoon-hyun Aug 6, 2020

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.

  1. OrcField looks a little mismatched because this function returns DataType instead of a field. Currently, it sounds likes ToOrcField.
  2. According to the behavior of this function, this ignores BinaryType, complexType, UserDefinedType. Also, function description doesn't mention the limitation at all. In order to be more clear, we had better have Searchable in the function name like the previous one (isSearchableType).

@@ -231,37 +229,37 @@ private[sql] object OrcFilters extends OrcFiltersBase {
// Since ORC 1.5.0 (ORC-323), we need to quote for column names with `.` characters
// in order to distinguish predicate pushdown for nested columns.

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.

Since we removed quoteIfNeeded in this file completely, I believe we can remove this old comment (231~232) together in both files v1.2(here) and v2.3.

checkFilterPredicate(Literal(1) >= $"_1", PredicateLeaf.Operator.LESS_THAN_EQUALS)
checkFilterPredicate(Literal(4) <= $"_1", PredicateLeaf.Operator.LESS_THAN)
withNestedOrcDataFrame(
(1 to 4).map(i => Tuple1(Option(i.toDouble)))) { case (inputDF, colName, _) =>

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.

indentation?

test("filter pushdown - decimal") {
withOrcDataFrame((1 to 4).map(i => Tuple1.apply(BigDecimal.valueOf(i)))) { implicit df =>
checkFilterPredicate($"_1".isNull, PredicateLeaf.Operator.IS_NULL)
withNestedOrcDataFrame((1 to 4)

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.

This format looks inconsistent from your other code change. Is this intentional due to some limitation?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You mean indentation?

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.

I mean (1 to 4).

@dongjoon-hyun dongjoon-hyun 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.

Thanks, @viirya . I finished one round review. Could you take a look at the comments?

@viirya

viirya commented Aug 7, 2020

Copy link
Copy Markdown
Member Author

Thanks @dongjoon-hyun for the review. Except for #28761 (comment), I think all other comments were addressed. I will add test coverage for that later.

@dongjoon-hyun

Copy link
Copy Markdown
Member

Yes, @viirya . For that one, let's do later in another PR.

@dongjoon-hyun dongjoon-hyun 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.

+1, LGTM (except one minor function naming comment)

@SparkQA

SparkQA commented Aug 7, 2020

Copy link
Copy Markdown

Test build #127180 has finished for PR 28761 at commit 558db46.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA

SparkQA commented Aug 7, 2020

Copy link
Copy Markdown

Test build #127182 has finished for PR 28761 at commit dc77290.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@dongjoon-hyun dongjoon-hyun 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.

Thank you, @viirya . GitHub Action passed.
Merged to master for Apache Spark 3.1 on December.
This will help other nested column PRs, too.

Thank you, @maropu and @HyukjinKwon , too.

cc @cloud-fan , @dbtsai , @gatorsmile , too.

@viirya

viirya commented Aug 7, 2020

Copy link
Copy Markdown
Member Author

Thanks all.

@HyukjinKwon

Copy link
Copy Markdown
Member

+1 looks good to me too

LuciferYang added a commit that referenced this pull request Aug 2, 2023
… `Filter`

### What changes were proposed in this pull request?
This pr aims remove `private[sql] `function `containsNestedColumn` from `org.apache.spark.sql.sources.Filter`.
This function was introduced by #27728 to avoid nested predicate pushdown for Orc.
After #28761, Orc also support nested column predicate pushdown, so this function become unused.

### Why are the changes needed?
Remove unused `private[sql] ` function `containsNestedColumn`.

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

### How was this patch tested?
Pass GitHub Actions

Closes #42239 from LuciferYang/SPARK-44607.

Authored-by: yangjie01 <yangjie01@baidu.com>
Signed-off-by: yangjie01 <yangjie01@baidu.com>
@viirya
viirya deleted the SPARK-25557 branch December 27, 2023 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants