-
Notifications
You must be signed in to change notification settings - Fork 117
Add lineage column(s) to index records #121
Changes from all commits
612885a
1298e24
495decf
8f7c586
4fdb8cc
211a328
f8ed0d0
edbc612
f0e5383
74f1ed7
a61e6a7
5d8c118
6451b9a
3cdb22f
11a0d1c
6522e0a
b55c884
88a483c
a5ec6d9
a9ed337
c76a35f
2083571
c8b80a3
e77b0ff
2611362
7bd60de
4b6b657
6b53112
7cdd529
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,4 +47,8 @@ object IndexConstants { | |
| val PLAIN_TEXT = "plaintext" | ||
| val HTML = "html" | ||
| } | ||
|
|
||
| private[hyperspace] val DATA_FILE_NAME_COLUMN = "_data_file_name" | ||
| val INDEX_LINEAGE_ENABLED = "spark.hyperspace.index.lineage.enabled" | ||
| val INDEX_LINEAGE_ENABLED_DEFAULT = "false" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to reviewers: For now, by default, I have disabled lineage for indexes - I already made sure that all test cases pass irrespective of this default value (i.e. all tests pass with this default value be true or false). |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,26 +136,26 @@ object JoinIndexRule | |
| * @return replacement plan | ||
| */ | ||
| private def getReplacementPlan(index: IndexLogEntry, plan: LogicalPlan): LogicalPlan = { | ||
| val bucketSpec = BucketSpec( | ||
| numBuckets = index.numBuckets, | ||
| bucketColumnNames = index.indexedColumns, | ||
| sortColumnNames = index.indexedColumns) | ||
|
|
||
| val location = new InMemoryFileIndex(spark, Seq(new Path(index.content.root)), Map(), None) | ||
| val relation = HadoopFsRelation( | ||
| location, | ||
| new StructType(), | ||
| index.schema, | ||
| Some(bucketSpec), | ||
| new ParquetFileFormat, | ||
| Map())(spark) | ||
|
|
||
| // Here we can't replace the plan completely with the index. This will create problems. | ||
| // For e.g. if Project(A,B) -> Filter(C = 10) -> Scan (A,B,C,D,E) | ||
| // if we replace this plan with index Scan (A,B,C), we lose the Filter(C=10) and it will | ||
| // lead to wrong results. So we only replace the base relation. | ||
| plan transform { | ||
| case baseRelation @ LogicalRelation(_: HadoopFsRelation, baseOutput, _, _) => | ||
| val bucketSpec = BucketSpec( | ||
| numBuckets = index.numBuckets, | ||
| bucketColumnNames = index.indexedColumns, | ||
| sortColumnNames = index.indexedColumns) | ||
|
|
||
| val location = new InMemoryFileIndex(spark, Seq(new Path(index.content.root)), Map(), None) | ||
| val relation = HadoopFsRelation( | ||
| location, | ||
| new StructType(), | ||
| StructType(index.schema.filter(baseRelation.schema.contains(_))), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about defining a new function for this like And I think
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently, we only have one extra column and your suggested code works fine. However, I think it is better if we rely on the source data schema to pick schema for an index usage. This way if we add more extra column(s) later; this code works as expected with no change required. @sezruby Please let me know if above is clear and makes sense to you.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the detailed explanation, but it's a bit unclear to me. The current version also just uses
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As current version uses index.schema it has a similar issue, however I updated my comment as I realized this behavior is actually desired. The reason for that is if the source data at the query time uses a subset of the original source data then we should not use index as it could have extra rows that were part of original data and now excluded from the source data at query time. Imagine the index was created on source data with two partitions:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I got the point. I might also need to investigate |
||
| Some(bucketSpec), | ||
| new ParquetFileFormat, | ||
| Map())(spark) | ||
|
|
||
| val updatedOutput = | ||
| baseOutput.filter(attr => relation.schema.fieldNames.contains(attr.name)) | ||
| baseRelation.copy(relation = relation, output = updatedOutput) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.