You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/08/31 08:12:12 UTC

[GitHub] [spark] 1zg12 opened a new pull request, #37738: add Support Java Class with circular references

1zg12 opened a new pull request, #37738:
URL: https://github.com/apache/spark/pull/37738

   <!--
   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
        'core/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.
   -->
   If the target Java data class has a circular reference, Spark will fail fast from creating the Dataset or running Encoders.
   
   This PR will add an option for developer to decide whether they would like to skip the circular field, or leave the application to fail.
   
   ### 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.
   -->
   
   If the target Java data class has a circular reference, Spark will fail fast from creating the Dataset or running Encoders.
   
   ### 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.
   -->
   
   Issue: https://issues.apache.org/jira/browse/SPARK-33598


-- 
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


[GitHub] [spark] jkhalid commented on pull request #37738: add Support Java Class with circular references

Posted by GitBox <gi...@apache.org>.
jkhalid commented on PR #37738:
URL: https://github.com/apache/spark/pull/37738#issuecomment-1329874628

   Hey All ,
   Is there any update on this PR. I am currently running into an issue where I have a JSON schema that has circular references I am using Encoders.bean(classOf[Example.class]) to map the input to the POJO generated from that schema .it fails because of the circular reference


-- 
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


[GitHub] [spark] venkyvb commented on pull request #37738: add Support Java Class with circular references

Posted by GitBox <gi...@apache.org>.
venkyvb commented on PR #37738:
URL: https://github.com/apache/spark/pull/37738#issuecomment-1358924659

   Hey all,
   Wondering if this PR (or some similar fix got merged). I have similar issues with circular references and it would be great to have an option to skip the check.
   Thanks.


-- 
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


[GitHub] [spark] 1zg12 commented on pull request #37738: add Support Java Class with circular references

Posted by GitBox <gi...@apache.org>.
1zg12 commented on PR #37738:
URL: https://github.com/apache/spark/pull/37738#issuecomment-1233696662

   > Hm, skipping them doesn't seem right either. Not sure if this should be an option; it is just something that doesn't make sense to encode
   
   If it's a field the developer/application is comfortable with having self/circular reference, from Spark perspective I think it should allow the developer to stop the loop gracefully (which is to skip further processing the field in loop at developers' own judgement).
   
   This PR is not to force for either way (stop the whole application immediately as existing or skip the filed if the developer choose to), but leave for the developer a choice to choose. Ultimately, it's the developer building their own application have best knowledge how to handle it.
   
   I guess Spark probably assumed the circular reference must be a mistake made by the developers/application earlier. But it can really be a valid case even it could be rare.


-- 
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


[GitHub] [spark] srowen closed pull request #37738: add Support Java Class with circular references

Posted by GitBox <gi...@apache.org>.
srowen closed pull request #37738: add Support Java Class with circular references
URL: https://github.com/apache/spark/pull/37738


-- 
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


[GitHub] [spark] srowen commented on pull request #37738: add Support Java Class with circular references

Posted by GitBox <gi...@apache.org>.
srowen commented on PR #37738:
URL: https://github.com/apache/spark/pull/37738#issuecomment-1233698787

   Can you describe a valid use case? I can't think of one. Encoders are used with data classes, bean-like classes


-- 
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


[GitHub] [spark] 1zg12 commented on pull request #37738: add Support Java Class with circular references

Posted by GitBox <gi...@apache.org>.
1zg12 commented on PR #37738:
URL: https://github.com/apache/spark/pull/37738#issuecomment-1233718230

   > Can you describe a valid use case? I can't think of one. Encoders are used with data classes, bean-like classes
   
   Google Protobuf is an example, it's widely used as a data class. In the protobuf class, there is an attribute called `Descriptor` (this is a generated filed) which circular reference back.
   
   Current spark implementation doesn't work with protobuf.
   
   There are some other examples on the issue:
   https://issues.apache.org/jira/browse/SPARK-33598


-- 
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


[GitHub] [spark] AmplabJenkins commented on pull request #37738: add Support Java Class with circular references

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on PR #37738:
URL: https://github.com/apache/spark/pull/37738#issuecomment-1233128192

   Can one of the admins verify this patch?


-- 
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


[GitHub] [spark] srowen commented on pull request #37738: add Support Java Class with circular references

Posted by "srowen (via GitHub)" <gi...@apache.org>.
srowen commented on PR #37738:
URL: https://github.com/apache/spark/pull/37738#issuecomment-1473647828

   Still seems weird to me --
   Does this happen to even be 'enough' for the protobuf case? Or does this extra unwanted descriptor field add other unneeded cols?
   Is it 'too much' - Is it skipping real circular references that matter, but can't translate to tabular schemas?
   Is it solvable by just subclassing the bean class and hiding the field that isn't desirable to begin with?
   How does the circular ref arise in the avro case, different?
   
   I get it just seems a bit too hacky as the 'right' solution. Sometimes hacks are worth it


-- 
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


[GitHub] [spark] srowen commented on pull request #37738: add Support Java Class with circular references

Posted by GitBox <gi...@apache.org>.
srowen commented on PR #37738:
URL: https://github.com/apache/spark/pull/37738#issuecomment-1233183779

   Hm, skipping them doesn't seem right either. Not sure if this should be an option; it is just something that doesn't make sense to encode


-- 
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


[GitHub] [spark] lsgrep commented on pull request #37738: add Support Java Class with circular references

Posted by "lsgrep (via GitHub)" <gi...@apache.org>.
lsgrep commented on PR #37738:
URL: https://github.com/apache/spark/pull/37738#issuecomment-1473419387

   Hi, I am having this `circular reference` problem while processing the Kafka `avro` messages with Spark 3.3.0. 
   
   ```
   Exception in thread "main" java.lang.UnsupportedOperationException: Cannot have circular references in bean class, but got the circular reference of class class org.apache.avro.Schema
   ```
   https://github.com/apache/avro/blob/master/lang/java/avro/src/main/java/org/apache/avro/Schema.java
   
   


-- 
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


[GitHub] [spark] lsgrep commented on pull request #37738: add Support Java Class with circular references

Posted by "lsgrep (via GitHub)" <gi...@apache.org>.
lsgrep commented on PR #37738:
URL: https://github.com/apache/spark/pull/37738#issuecomment-1473421694

   Hi @srowen , would you consider supporting `avro` schemas as a valid reason for supporting this feature as `avro` is pretty popular in general? Thanks


-- 
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