-
Notifications
You must be signed in to change notification settings - Fork 9
Retrieve source uri prefix from hive partitioning options when building the GCS format #204
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
19c8c7b
Fix uri suffix removal for when external table has a uri like /*.parquet
david-zlai d96d42d
actually strip smh
david-zlai 68b8650
format is uppercase so need to lower
david-zlai 24e613a
use hive partitioning option source uri prefix.
david-zlai 4f5eb6a
fix scalafix
david-zlai 7f46130
fallback
david-zlai b778d03
coderabbit did it better than me
david-zlai b7e9ea2
scalafix:
david-zlai 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| ZIPLINE_CUSTOMER_ID=canary | ||
| ZIPLINE_GCP_PROJECT_ID=canary-443022 | ||
| ZIPLINE_GCP_REGION=us-central1 | ||
| ZIPLINE_GCP_DATAPROC_CLUSTER_NAME=zipline-canary-cluster | ||
| ZIPLINE_GCP_DATAPROC_CLUSTER_NAME=canary-2 | ||
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 |
|---|---|---|
|
|
@@ -16,8 +16,6 @@ import org.apache.spark.sql.functions.col | |
| import org.apache.spark.sql.functions.date_format | ||
| import org.apache.spark.sql.functions.to_date | ||
|
|
||
| import scala.collection.JavaConverters._ | ||
|
|
||
| case class GcpFormatProvider(sparkSession: SparkSession) extends FormatProvider { | ||
| // Order of Precedence for Default Project | ||
| // Explicitly configured project in code (e.g., setProjectId()). | ||
|
|
@@ -62,22 +60,22 @@ case class GcpFormatProvider(sparkSession: SparkSession) extends FormatProvider | |
| .map((table) => { | ||
|
|
||
| if (table.getDefinition.isInstanceOf[ExternalTableDefinition]) { | ||
| val uris = table.getDefinition | ||
| .asInstanceOf[ExternalTableDefinition] | ||
| .getSourceUris | ||
| .asScala | ||
| .toList | ||
| .map((uri) => uri.stripSuffix("/*") + "/") | ||
|
|
||
| assert(uris.length == 1, s"External table ${tableName} can be backed by only one URI.") | ||
|
|
||
| val formatStr = table.getDefinition | ||
| .asInstanceOf[ExternalTableDefinition] | ||
| .getFormatOptions | ||
| .asInstanceOf[FormatOptions] | ||
| .getType | ||
|
|
||
| GCS(table.getTableId.getProject, uris.head, formatStr) | ||
| val externalTable = table.getDefinition.asInstanceOf[ExternalTableDefinition] | ||
| val uri = Option(externalTable.getHivePartitioningOptions) | ||
| .map(_.getSourceUriPrefix) | ||
| .getOrElse { | ||
| val uris = externalTable.getSourceUris | ||
| require(uris.size == 1, s"External table ${tableName} can be backed by only one URI.") | ||
| uris.get(0).replaceAll("/\\*\\.parquet$", "") | ||
|
Collaborator
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. sounds good, thanks. Would be great to unit test this but not a big deal. |
||
| } | ||
| GCS(table.getTableId.getProject, uri, formatStr) | ||
|
|
||
| } else if (table.getDefinition.isInstanceOf[StandardTableDefinition]) { | ||
| BQuery(table.getTableId.getProject, Map.empty) | ||
| } else throw new IllegalStateException(s"Cannot support table of type: ${table.getDefinition}") | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this change?