You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "allisonwang-db (via GitHub)" <gi...@apache.org> on 2024/11/26 09:43:05 UTC
[PR] [SPARK-50426][PYTHON] Avoid static Python data source lookup when using builtin or Java data sources [spark]
allisonwang-db opened a new pull request, #48971:
URL: https://github.com/apache/spark/pull/48971
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
4. Be sure to keep the PR description updated to reflect all changes.
5. Please write your PR title to summarize what this PR proposes.
6. If possible, provide a concise example to reproduce the issue for a faster review.
7. If you want to add a new configuration, please read the guideline first for naming configurations in
'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
8. If you want to add or modify an error type or message, please read the guideline first in
'common/utils/src/main/resources/error/README.md'.
-->
### What changes were proposed in this pull request?
<!--
Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
2. If you fix some SQL features, you can provide some references of other DBMSes.
3. If there is design documentation, please add the link.
4. If there is a discussion in the mailing list, please add the link.
-->
This PR updates the data source lookup logic to avoid triggering expensive Python data source lookups when the data source is a built-in or Java data source.
### Why are the changes needed?
<!--
Please clarify why the changes are needed. For instance,
1. If you propose a new API, clarify the use case for a new API.
2. If you fix a bug, you can clarify why it is a bug.
-->
Python data source lookups can be expensive, and they are often unnecessary when users only use built-in or Java data sources. The primary benefit of the lookup is to display a better error message when a Java data source and a Python data source share the same name, which can be rare. In these cases, we can simply prefer loading Java data sources instead of throwing exceptions.
### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as the documentation fix.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
If no, write 'No'.
-->
No.
### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
-->
New UT.
### Was this patch authored or co-authored using generative AI tooling?
<!--
If generative AI tooling has been used in the process of authoring this patch, please include the
phrase: 'Generated-by: ' followed by the name of the tool and its version.
If no, write 'No'.
Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
-->
No
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-50426][PYTHON] Avoid static Python data source lookup when using builtin or Java data sources [spark]
Posted by "allisonwang-db (via GitHub)" <gi...@apache.org>.
allisonwang-db commented on PR #48971:
URL: https://github.com/apache/spark/pull/48971#issuecomment-2500225236
cc @HyukjinKwon @cloud-fan this is an alternative (and better) approach to https://github.com/apache/spark/pull/48888 to avoid necessary Python data source lookup. And it eliminates the need for users to change the static conf.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-50426][PYTHON] Avoid static Python data source lookup when using builtin or Java data sources [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #48971:
URL: https://github.com/apache/spark/pull/48971#discussion_r1858658711
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSource.scala:
##########
@@ -682,10 +682,6 @@ object DataSource extends Logging {
throw e
}
}
- case _ :: Nil if isUserDefinedDataSource =>
- // There was DSv1 or DSv2 loaded, but the same name source was found
- // in user defined data source.
- throw QueryCompilationErrors.foundMultipleDataSources(provider)
Review Comment:
Given the cost of loading the python data sources, I feel it's better to give up producing a better error message here, and just say that Java data source will be picked over Python if the short name conflicts.
We must document this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-50426][PYTHON] Avoid static Python data source lookup when using builtin or Java data sources [spark]
Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #48971:
URL: https://github.com/apache/spark/pull/48971#discussion_r1858299764
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSource.scala:
##########
@@ -682,10 +682,6 @@ object DataSource extends Logging {
throw e
}
}
- case _ :: Nil if isUserDefinedDataSource =>
- // There was DSv1 or DSv2 loaded, but the same name source was found
- // in user defined data source.
- throw QueryCompilationErrors.foundMultipleDataSources(provider)
Review Comment:
Can we at least document that Scala/JVM short names will be used when the short names are conflicted with Python Data Source?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-50426][PYTHON] Avoid static Python data source lookup when using builtin or Java data sources [spark]
Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #48971:
URL: https://github.com/apache/spark/pull/48971#discussion_r1859485623
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSource.scala:
##########
@@ -682,10 +682,6 @@ object DataSource extends Logging {
throw e
}
}
- case _ :: Nil if isUserDefinedDataSource =>
- // There was DSv1 or DSv2 loaded, but the same name source was found
- // in user defined data source.
- throw QueryCompilationErrors.foundMultipleDataSources(provider)
Review Comment:
SG
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-50426][PYTHON] Avoid static Python data source lookup when using builtin or Java data sources [spark]
Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #48971:
URL: https://github.com/apache/spark/pull/48971#discussion_r1860019250
##########
python/docs/source/user_guide/sql/python_data_source.rst:
##########
@@ -516,3 +516,8 @@ The following example demonstrates how to implement a basic Data Source using Ar
df = spark.read.format("arrowbatch").load()
df.show()
+
+Usage Notes
+-----------
+
+- During data source resolution, built-in and Java data sources take precedence over Python data sources with the same name; to explicitly use a Python data source, make sure its name does not conflict with any other loaded Java data sources.
Review Comment:
```suggestion
- During Data Source resolution, built-in and Scala/Java Data Sources take precedence over Python Data Sources with the same name; to explicitly use a Python Data Source, make sure its name does not conflict with the other Data Sources.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-50426][PYTHON] Avoid static Python data source lookup when using builtin or Java data sources [spark]
Posted by "allisonwang-db (via GitHub)" <gi...@apache.org>.
allisonwang-db commented on code in PR #48971:
URL: https://github.com/apache/spark/pull/48971#discussion_r1860009837
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSource.scala:
##########
@@ -682,10 +682,6 @@ object DataSource extends Logging {
throw e
}
}
- case _ :: Nil if isUserDefinedDataSource =>
- // There was DSv1 or DSv2 loaded, but the same name source was found
- // in user defined data source.
- throw QueryCompilationErrors.foundMultipleDataSources(provider)
Review Comment:
Sg! Added usage notes in the python data source user guide.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-50426][PYTHON] Avoid static Python data source lookup when using builtin or Java data sources [spark]
Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #48971:
URL: https://github.com/apache/spark/pull/48971#discussion_r1858296198
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSource.scala:
##########
@@ -682,10 +682,6 @@ object DataSource extends Logging {
throw e
}
}
- case _ :: Nil if isUserDefinedDataSource =>
- // There was DSv1 or DSv2 loaded, but the same name source was found
- // in user defined data source.
- throw QueryCompilationErrors.foundMultipleDataSources(provider)
Review Comment:
I think we should still throw an exception if one is found with a short name, but another one is found in Python Data Source.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-50426][PYTHON] Avoid static Python data source lookup when using builtin or Java data sources [spark]
Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #48971:
URL: https://github.com/apache/spark/pull/48971#discussion_r1860019250
##########
python/docs/source/user_guide/sql/python_data_source.rst:
##########
@@ -516,3 +516,8 @@ The following example demonstrates how to implement a basic Data Source using Ar
df = spark.read.format("arrowbatch").load()
df.show()
+
+Usage Notes
+-----------
+
+- During data source resolution, built-in and Java data sources take precedence over Python data sources with the same name; to explicitly use a Python data source, make sure its name does not conflict with any other loaded Java data sources.
Review Comment:
```suggestion
- During Data Source resolution, built-in and Scala/Java Data Sources take precedence over Python Data Sources with the same name; to explicitly use a Python Data Source, make sure its name does not conflict with the other Data Sources.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-50426][PYTHON] Avoid static Python data source lookup when using builtin or Java data sources [spark]
Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #48971:
URL: https://github.com/apache/spark/pull/48971#discussion_r1860026764
##########
python/docs/source/user_guide/sql/python_data_source.rst:
##########
@@ -516,3 +516,8 @@ The following example demonstrates how to implement a basic Data Source using Ar
df = spark.read.format("arrowbatch").load()
df.show()
+
+Usage Notes
+-----------
+
+- During Data Source resolution, built-in and Scala/Java Data Sources take precedence over Python Data Sources with the same name; to explicitly use a Python Data Source, make sure its name does not conflict with the other Data Sources.
Review Comment:
BTW, I think we should deal with the case when there are multiple Python Data Sources having the same names in a separate PR
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-50426][PYTHON] Avoid static Python data source lookup when using builtin or Java data sources [spark]
Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #48971:
URL: https://github.com/apache/spark/pull/48971#discussion_r1860026764
##########
python/docs/source/user_guide/sql/python_data_source.rst:
##########
@@ -516,3 +516,8 @@ The following example demonstrates how to implement a basic Data Source using Ar
df = spark.read.format("arrowbatch").load()
df.show()
+
+Usage Notes
+-----------
+
+- During Data Source resolution, built-in and Scala/Java Data Sources take precedence over Python Data Sources with the same name; to explicitly use a Python Data Source, make sure its name does not conflict with the other Data Sources.
Review Comment:
BTW, I think we should deal with the case when there are multiple Python Data Sources having the same names
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-50426][PYTHON] Avoid static Python data source lookup when using builtin or Java data sources [spark]
Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon closed pull request #48971: [SPARK-50426][PYTHON] Avoid static Python data source lookup when using builtin or Java data sources
URL: https://github.com/apache/spark/pull/48971
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-50426][PYTHON] Avoid static Python data source lookup when using builtin or Java data sources [spark]
Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on PR #48971:
URL: https://github.com/apache/spark/pull/48971#issuecomment-2503192143
Merged to master.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org