Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HUDI-8432] Fix data skipping with RLI if record key is composite #12160

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

codope
Copy link
Member

@codope codope commented Oct 24, 2024

Change Logs

Fix data skipping with RLI if record key is composite. When there are multiple record key fields, we need to form the record keys sequence correctly. Added a test to show skipping with more than one record key fields.

Impact

Support data skipping for complex primary keys

Risk level (write none, low medium or high below)

low

Documentation Update

Describe any necessary documentation update if there is any new feature, config, or user-facing change. If not, put "none".

  • The config description must be updated if new configs are added or the default value of the configs are changed
  • Any new feature or user-facing change requires updating the Hudi website. Please create a Jira ticket, attach the
    ticket number here and follow the instruction to make
    changes to the website.

Contributor's checklist

  • Read through contributor's guide
  • Change Logs and Impact were stated clearly
  • Adequate tests were added if applicable
  • CI passed

@github-actions github-actions bot added the size:M PR with lines of changes in (100, 300] label Oct 24, 2024
if (attribute != null && attribute.name != null && attributeMatchesRecordKey(attribute.name, recordKeyOpt)) {
Option.apply(equalToQuery, List.apply(literal.value.toString))
if (attribute != null && attribute.name != null && recordKeyOpt.contains(attribute.name)) {
val recordKeyLiteral = getRecordKeyLiteral(attribute, literal, isComplexRecordKey)
Copy link
Contributor

Choose a reason for hiding this comment

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

How can we ensure all the consitituent record key values got involved in the expression?

Copy link
Member Author

Choose a reason for hiding this comment

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

good point.. we should check if the predicate contains all of record key fields. Technically, we can support subset of record key fields as well but that involves pulling all records in RLI and checking for subset match. Something to followup. For now, we can just see if all record key fields are present or not. If not, then don't use RLI. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

For now, we can just see if all record key fields are present or not. If not, then don't use RLI. What do you think?

I kind of think we should also restrain all the expression type to EQUALS. For e.g, we have record key col_0,col_1 and expression col_0 >0 && col_1 <100, you can not utilitize RLI in sucn use case.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes.

  • lets do RLI look up only when all fields in complex key gen are part of the predicates.
  • If I am not wrong, we already only support "IN" and "EQUAL"s. So, not sure what Danny is bringing up.

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't support range queries with RLI, so it will fallback to no data skipping (exxcept for partition pruning which is done before we read RLI).

Copy link
Contributor

Choose a reason for hiding this comment

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

We need to check all the record key fields are got involved.

@codope codope force-pushed the hudi-8432-rec-index-complex branch from 2ecc9e7 to b20398a Compare October 25, 2024 13:12
@hudi-bot
Copy link

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

}

// Handle Or expression (for completeness, though usually not used for record key filtering)
case orQuery: Or =>
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess the OR does not work as expected.

validINQuery = false
}
case _ => validINQuery = false
}
var literals: List[String] = List.empty
inQuery.list.foreach {
case literal: Literal => literals = literals :+ literal.value.toString
case literal: Literal => literals = literals :+ getRecordKeyLiteral(inQuery.value.asInstanceOf[AttributeReference], literal, isComplexRecordKey)
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to check all the record key fields are got involved.

}))
Option.apply(recordKeyOpt.orElse(null))
// Convert the Hudi Option to Scala Option and return if present
Option(recordKeysOpt.orElse(null)).filter(_.nonEmpty)
Copy link
Contributor

Choose a reason for hiding this comment

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

The nonEmpty does now work when the record key is null.

verifyEqualToQuery(hudiOpts, Seq("record_key_col", "name"), tableName, latestSnapshotDf, HoodieTableMetaClient.reload(metaClient))
}

def verifyEqualToQuery(hudiOpts: Map[String, String], colNames: Seq[String], tableName: String, latestSnapshotDf: DataFrame, metaClient: HoodieTableMetaClient): Unit = {
Copy link
Contributor

Choose a reason for hiding this comment

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

also valite IN and AND.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:M PR with lines of changes in (100, 300]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants