-
Notifications
You must be signed in to change notification settings - Fork 29.2k
[SPARK-55729][SS] Support state data source reader for new state format v4 on stream-stream join #54845
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
Closed
Closed
[SPARK-55729][SS] Support state data source reader for new state format v4 on stream-stream join #54845
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
75ab3d1
WIP support state data source reader for stream-stream join v4
HeartSaVioR 7a7c661
address review comments (from Claude)
HeartSaVioR 1bf8604
update todo message
HeartSaVioR b2b29d3
remove TODO comment - we already have e2e test in other place
HeartSaVioR 3902f7b
fix tests
HeartSaVioR 7642952
reflect review comments
HeartSaVioR 678582c
fix test
HeartSaVioR e4f13b0
Address review comment from Anish
HeartSaVioR 1f1fd48
Address Dylan's review comments
HeartSaVioR File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,13 +50,13 @@ object StreamStreamJoinStateHelper { | |
| .add("value", valueSchema) | ||
| } | ||
|
|
||
| // Returns whether the checkpoint uses stateFormatVersion 3 which uses VCF for the join. | ||
| // Returns whether the checkpoint uses VCF for the join (stateFormatVersion >= 3). | ||
| def usesVirtualColumnFamilies( | ||
| hadoopConf: Configuration, | ||
| stateCheckpointLocation: String, | ||
| operatorId: Int): Boolean = { | ||
| // If the schema exists for operatorId/partitionId/left-keyToNumValues, it is not | ||
| // stateFormatVersion 3. | ||
| // stateFormatVersion >= 3 (which uses VCF). | ||
| val partitionId = StateStore.PARTITION_ID_TO_CHECK_SCHEMA | ||
| val storeId = new StateStoreId(stateCheckpointLocation, operatorId, | ||
| partitionId, SymmetricHashJoinStateManager.allStateStoreNames(LeftSide).toList.head) | ||
|
|
@@ -76,12 +76,12 @@ object StreamStreamJoinStateHelper { | |
|
|
||
| val newHadoopConf = session.sessionState.newHadoopConf() | ||
| val partitionId = StateStore.PARTITION_ID_TO_CHECK_SCHEMA | ||
| // KeyToNumValuesType, KeyWithIndexToValueType | ||
| val storeNames = SymmetricHashJoinStateManager.allStateStoreNames(side).toList | ||
|
|
||
| val (keySchema, valueSchema) = | ||
| if (!usesVirtualColumnFamilies( | ||
| newHadoopConf, stateCheckpointLocation, operatorId)) { | ||
| // v1/v2: separate state stores per store type | ||
| val storeIdForKeyToNumValues = new StateStoreId(stateCheckpointLocation, operatorId, | ||
| partitionId, storeNames(0)) | ||
| val providerIdForKeyToNumValues = new StateStoreProviderId(storeIdForKeyToNumValues, | ||
|
|
@@ -105,29 +105,40 @@ object StreamStreamJoinStateHelper { | |
|
|
||
| (kSchema, vSchema) | ||
| } else { | ||
| // v3/v4: single state store with virtual column families | ||
| val storeId = new StateStoreId(stateCheckpointLocation, operatorId, | ||
| partitionId, StateStoreId.DEFAULT_STORE_NAME) | ||
| val providerId = new StateStoreProviderId(storeId, UUID.randomUUID()) | ||
|
|
||
| val manager = new StateSchemaCompatibilityChecker( | ||
| providerId, newHadoopConf, oldSchemaFilePaths, createSchemaDir = false) | ||
| val kSchema = manager.readSchemaFile().find { schema => | ||
| schema.colFamilyName == storeNames(0) | ||
| }.map(_.keySchema).get | ||
| val schemas = manager.readSchemaFile() | ||
|
|
||
| val vSchema = manager.readSchemaFile().find { schema => | ||
| schema.colFamilyName == storeNames(1) | ||
| }.map(_.valueSchema).get | ||
| // Try v3 CF names first; if not found, use v4 CF names | ||
|
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. Why so ? we have the format version in the offset log right ? |
||
| val v3Names = storeNames | ||
| val v4Names = SymmetricHashJoinStateManager.allStateStoreNamesV4(side).toList | ||
|
|
||
| val primaryCfName = schemas.find(_.colFamilyName == v3Names(1)) match { | ||
| case Some(_) => v3Names(1) // v3: keyWithIndexToValue | ||
| case None => v4Names(0) // v4: keyWithTsToValues | ||
| } | ||
| val keyCfName = schemas.find(_.colFamilyName == v3Names(0)) match { | ||
| case Some(_) => v3Names(0) // v3: keyToNumValues | ||
| case None => v4Names(0) // v4: keyWithTsToValues (key schema is the join key) | ||
| } | ||
|
|
||
| val kSchema = schemas.find(_.colFamilyName == keyCfName).map(_.keySchema).get | ||
| val vSchema = schemas.find(_.colFamilyName == primaryCfName).map(_.valueSchema).get | ||
|
|
||
| (kSchema, vSchema) | ||
| } | ||
|
|
||
| val maybeMatchedColumn = valueSchema.last | ||
|
|
||
| // remove internal column `matched` for format version >= 2 | ||
| if (excludeAuxColumns | ||
| && maybeMatchedColumn.name == "matched" | ||
| && maybeMatchedColumn.dataType == BooleanType) { | ||
| // remove internal column `matched` for format version 2 | ||
| (keySchema, StructType(valueSchema.dropRight(1))) | ||
| } else { | ||
| (keySchema, valueSchema) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.