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 2021/03/31 12:30:45 UTC

[GitHub] [spark] tanelk opened a new pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

tanelk opened a new pull request #32014:
URL: https://github.com/apache/spark/pull/32014


   <!--
   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'.
   -->
   
   ### 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.
   -->
   Changed the cost comparison function of the CBO to use the ratios of row counts and sizes in bytes.
   
   ### 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.
   -->
   In #30965 we changed to CBO cost comparison function so it would be "symetric": `A.betterThan(B)` now implies, that `!B.betterThan(A)`.
   With that we caused a performance regressions in some queries - TPCDS q19 for example.
   
   The original cost comparison function used the ratios `relativeRows = A.rowCount / B.rowCount` and `relativeSize = A.size / B.size`. The changed function compared "absolute" cost values `costA = w*A.rowCount + (1-w)*A.size` and `costB = w*B.rowCount + (1-w)*B.size`.
   
   Given the input from @wzhfy we decided to go back to the relative values, because otherwise one (size) may overwhelm the other (rowCount). But this time we avoid adding up the ratios.
   
   Originally `A.betterThan(B) => w*relativeRows + (1-w)*relativeSize < 1` was used. Besides being "non-symteric", this also can exhibit one overwhelming other. 
   For `w=0.5` If `A` size (bytes) is at least 2x larger than `B`, then no matter how many times more rows does the `B` plan have, `B` will allways be considered to be better - `0.5*2 + 0.5*0.00000000000001 > 1`.
   
   When working with ratios, then it would be better to multiply them.
   The proposed cost comparison function is: `A.betterThan(B) => relativeRows^w  * relativeSize^(1-w) < 1`.
   
   ### 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'.
   -->
   Comparison of the changed TPCDS v1.4 query execution times at sf=10:
   
     | absolute | multiplicative |   | additive |  
   -- | -- | -- | -- | -- | --
   q12 | 145 | 137 | -5.52% | 141 | -2.76%
   q13 | 264 | 271 | 2.65% | 271 | 2.65%
   q17 | 4521 | 4243 | -6.15% | 4348 | -3.83%
   q18 | 758 | 466 | -38.52% | 480 | -36.68%
   q19 | 38503 | 2167 | -94.37% | 2176 | -94.35%
   q20 | 119 | 120 | 0.84% | 126 | 5.88%
   q24a | 16429 | 16838 | 2.49% | 17103 | 4.10%
   q24b | 16592 | 16999 | 2.45% | 17268 | 4.07%
   q25 | 3558 | 3556 | -0.06% | 3675 | 3.29%
   q33 | 362 | 361 | -0.28% | 380 | 4.97%
   q52 | 1020 | 1032 | 1.18% | 1052 | 3.14%
   q55 | 927 | 938 | 1.19% | 961 | 3.67%
   q72 | 24169 | 13377 | -44.65% | 24306 | 0.57%
   q81 | 1285 | 1185 | -7.78% | 1168 | -9.11%
   q91 | 324 | 336 | 3.70% | 337 | 4.01%
   q98 | 126 | 129 | 2.38% | 131 | 3.97%
   
   All times are in ms, the change is compared to the situation in the master branch (absolute). 
   The proposed cost function (multiplicative) significantlly improves the performance on q18, q19 and q72. The original cost function (additive) has similar improvements at q18 and q19. All other chagnes are within the error bars and I would ignore them.
   
   ### 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.
   -->
   PlanStabilitySuite


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

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] SparkQA commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-812475460


   Kubernetes integration test status success
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/41429/
   


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

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] maropu commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
maropu commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-811883369


   cc: @wzhfy 


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

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] SparkQA commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-811848343


   **[Test build #136799 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/136799/testReport)** for PR 32014 at commit [`41b46a8`](https://github.com/apache/spark/commit/41b46a864dca21b303349971ab091c25c741fa37).
    * This patch passes all tests.
    * This patch merges cleanly.
    * This patch adds no public 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.

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 #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

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


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/41530/
   


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

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] SparkQA commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-811686050


   **[Test build #136799 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/136799/testReport)** for PR 32014 at commit [`41b46a8`](https://github.com/apache/spark/commit/41b46a864dca21b303349971ab091c25c741fa37).


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

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 #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

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


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/136954/
   


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

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 #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

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


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/41429/
   


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

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] maropu closed pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
maropu closed pull request #32014:
URL: https://github.com/apache/spark/pull/32014


   


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

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 removed a comment on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-814328867


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/136954/
   


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

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] tanelk commented on a change in pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
tanelk commented on a change in pull request #32014:
URL: https://github.com/apache/spark/pull/32014#discussion_r607910045



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/CostBasedJoinReorder.scala
##########
@@ -349,11 +349,14 @@ object JoinReorderDP extends PredicateHelper with Logging {
     }
 
     def betterThan(other: JoinPlan, conf: SQLConf): Boolean = {
-      val thisCost = BigDecimal(this.planCost.card) * conf.joinReorderCardWeight +
-        BigDecimal(this.planCost.size) * (1 - conf.joinReorderCardWeight)
-      val otherCost = BigDecimal(other.planCost.card) * conf.joinReorderCardWeight +
-        BigDecimal(other.planCost.size) * (1 - conf.joinReorderCardWeight)
-      thisCost < otherCost
+      if (other.planCost.card == 0 || other.planCost.size == 0) {
+        false
+      } else {

Review comment:
       Added some comments to this method.




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

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 #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

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


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/136799/
   


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

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] maropu commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
maropu commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-814556124


   The GA test failures is not related to this PR, so 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.

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] cloud-fan commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-814202792


   Unfortunately there are conflicts again...


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

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] SparkQA commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-814198997


   **[Test build #136954 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/136954/testReport)** for PR 32014 at commit [`a7406e7`](https://github.com/apache/spark/commit/a7406e7ee9c628d08bc237e2ac688e08a7cb2bc6).


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

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] SparkQA removed a comment on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-811038834


   **[Test build #136768 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/136768/testReport)** for PR 32014 at commit [`811c1c9`](https://github.com/apache/spark/commit/811c1c9f834f28afc6fe8fd9ae35719b9fb8b5d2).


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

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] tanelk commented on a change in pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
tanelk commented on a change in pull request #32014:
URL: https://github.com/apache/spark/pull/32014#discussion_r604888377



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/CostBasedJoinReorder.scala
##########
@@ -349,11 +349,14 @@ object JoinReorderDP extends PredicateHelper with Logging {
     }
 
     def betterThan(other: JoinPlan, conf: SQLConf): Boolean = {
-      val thisCost = BigDecimal(this.planCost.card) * conf.joinReorderCardWeight +
-        BigDecimal(this.planCost.size) * (1 - conf.joinReorderCardWeight)
-      val otherCost = BigDecimal(other.planCost.card) * conf.joinReorderCardWeight +
-        BigDecimal(other.planCost.size) * (1 - conf.joinReorderCardWeight)
-      thisCost < otherCost
+      if (other.planCost.card == 0 || other.planCost.size == 0) {
+        false
+      } else {
+        val relativeRows = BigDecimal(this.planCost.card) / BigDecimal(other.planCost.card)
+        val relativeSize = BigDecimal(this.planCost.size) / BigDecimal(other.planCost.size)
+        Math.pow(relativeRows.doubleValue(), conf.joinReorderCardWeight) *
+          Math.pow(relativeSize.doubleValue(), 1 - conf.joinReorderCardWeight) < 1

Review comment:
       If I'm not mistaken, then, when the left side is `x` for `A.betterThan(B)`, then for `B.betterThan(A)` it will be `1/x`. One of them will be greater than 1 and other smaller.




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

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] SparkQA commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-814288591






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

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] SparkQA commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-814427896


   **[Test build #136958 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/136958/testReport)** for PR 32014 at commit [`cdf7f08`](https://github.com/apache/spark/commit/cdf7f08bc7bdda6dd5abe542b3961f2bc4ac4057).
    * This patch passes all tests.
    * This patch merges cleanly.
    * This patch adds the following public classes _(experimental)_:
     * `class KoalasFrameMethods(object):`
     * `class KoalasSeriesMethods(object):`
     * `class IndexOpsMixin(object, metaclass=ABCMeta):`
     * `class CategoricalAccessor(object):`
     * `    however, expected types are [(<class 'float'>, <class 'int'>)].`
     * `class OptionError(AttributeError, KeyError):`
     * `class DatetimeMethods(object):`
     * `class DataError(Exception):`
     * `class SparkPandasIndexingError(Exception):`
     * `class SparkPandasNotImplementedError(NotImplementedError):`
     * `class PandasNotImplementedError(NotImplementedError):`
     * `            new_class = type(\"NameType\", (NameTypeHolder,), `
     * `            new_class = type(\"NameType\", (NameTypeHolder,), `
     * `class DataFrame(Frame, Generic[T]):`
     * `        [defaultdict(<class 'list'>, `
     * `defaultdict(<class 'list'>, `
     * `class CachedDataFrame(DataFrame):`
     * `class Frame(object, metaclass=ABCMeta):`
     * `class GroupBy(object, metaclass=ABCMeta):`
     * `class DataFrameGroupBy(GroupBy):`
     * `class SeriesGroupBy(GroupBy):`
     * `class Index(IndexOpsMixin):`
     * `class CategoricalIndex(Index):`
     * `class DatetimeIndex(Index):`
     * `class MultiIndex(Index):`
     * `            a single :class:`Index` (or subclass thereof).`
     * `class NumericIndex(Index):`
     * `class IntegerIndex(NumericIndex):`
     * `class Int64Index(IntegerIndex):`
     * `class Float64Index(NumericIndex):`
     * `class IndexerLike(object):`
     * `class AtIndexer(IndexerLike):`
     * `class iAtIndexer(IndexerLike):`
     * `class LocIndexerLike(IndexerLike, metaclass=ABCMeta):`
     * `class LocIndexer(LocIndexerLike):`
     * `class iLocIndexer(LocIndexerLike):`
     * `class InternalFrame(object):`
     * `class _MissingPandasLikeDataFrame(object):`
     * `class MissingPandasLikeDataFrameGroupBy(object):`
     * `class MissingPandasLikeSeriesGroupBy(object):`
     * `class MissingPandasLikeIndex(object):`
     * `class MissingPandasLikeDatetimeIndex(MissingPandasLikeIndex):`
     * `class MissingPandasLikeCategoricalIndex(MissingPandasLikeIndex):`
     * `class MissingPandasLikeMultiIndex(object):`
     * `class MissingPandasLikeSeries(object):`
     * `class MissingPandasLikeExpanding(object):`
     * `class MissingPandasLikeRolling(object):`
     * `class MissingPandasLikeExpandingGroupby(object):`
     * `class MissingPandasLikeRollingGroupby(object):`
     * `class PythonModelWrapper(object):`
     * `class KoalasPlotAccessor(PandasObject):`
     * `class KoalasBarPlot(PandasBarPlot, TopNPlotBase):`
     * `class KoalasBoxPlot(PandasBoxPlot, BoxPlotBase):`
     * `class KoalasHistPlot(PandasHistPlot, HistogramPlotBase):`
     * `class KoalasPiePlot(PandasPiePlot, TopNPlotBase):`
     * `class KoalasAreaPlot(PandasAreaPlot, SampledPlotBase):`
     * `class KoalasLinePlot(PandasLinePlot, SampledPlotBase):`
     * `class KoalasBarhPlot(PandasBarhPlot, TopNPlotBase):`
     * `class KoalasScatterPlot(PandasScatterPlot, TopNPlotBase):`
     * `class KoalasKdePlot(PandasKdePlot, KdePlotBase):`
     * `        new_class = type(\"NameType\", (NameTypeHolder,), `
     * `        new_class = param.type if isinstance(param, np.dtype) else param`
     * `class Series(Frame, IndexOpsMixin, Generic[T]):`
     * `        dictionary is a ``dict`` subclass that defines ``__missing__`` (i.e.`
     * `        defaultdict(<class 'list'>, `
     * `class SparkIndexOpsMethods(object, metaclass=ABCMeta):`
     * `class SparkSeriesMethods(SparkIndexOpsMethods):`
     * `class SparkIndexMethods(SparkIndexOpsMethods):`
     * `class SparkFrameMethods(object):`
     * `class CachedSparkFrameMethods(SparkFrameMethods):`
     * `class SQLProcessor(object):`
     * `class StringMethods(object):`
     * `class SeriesType(Generic[T]):`
     * `class DataFrameType(object):`
     * `class ScalarType(object):`
     * `class UnknownType(object):`
     * `class NameTypeHolder(object):`
     * `    The returned type class indicates both dtypes (a pandas only dtype object`
     * `class KoalasUsageLogger(object):`
     * `class RollingAndExpanding(object):`
     * `class Rolling(RollingAndExpanding):`
     * `class RollingGroupby(Rolling):`
     * `class Expanding(RollingAndExpanding):`
     * `class ExpandingGroupby(Expanding):`


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

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 #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

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


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/136851/
   


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

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] maropu commented on a change in pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
maropu commented on a change in pull request #32014:
URL: https://github.com/apache/spark/pull/32014#discussion_r605628437



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/CostBasedJoinReorder.scala
##########
@@ -349,11 +349,14 @@ object JoinReorderDP extends PredicateHelper with Logging {
     }
 
     def betterThan(other: JoinPlan, conf: SQLConf): Boolean = {
-      val thisCost = BigDecimal(this.planCost.card) * conf.joinReorderCardWeight +
-        BigDecimal(this.planCost.size) * (1 - conf.joinReorderCardWeight)
-      val otherCost = BigDecimal(other.planCost.card) * conf.joinReorderCardWeight +
-        BigDecimal(other.planCost.size) * (1 - conf.joinReorderCardWeight)
-      thisCost < otherCost
+      if (other.planCost.card == 0 || other.planCost.size == 0) {
+        false
+      } else {

Review comment:
       How about leaving some comments about why we need to use relative values here?




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

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] maropu commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
maropu commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-814556299


   Could you open PRs to backport this for branch-3.1/3.0, too?


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

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 #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

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


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/41363/
   


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

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 removed a comment on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-811851338


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/136799/
   


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

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] cloud-fan commented on a change in pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #32014:
URL: https://github.com/apache/spark/pull/32014#discussion_r607129160



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/CostBasedJoinReorder.scala
##########
@@ -349,11 +349,14 @@ object JoinReorderDP extends PredicateHelper with Logging {
     }
 
     def betterThan(other: JoinPlan, conf: SQLConf): Boolean = {
-      val thisCost = BigDecimal(this.planCost.card) * conf.joinReorderCardWeight +
-        BigDecimal(this.planCost.size) * (1 - conf.joinReorderCardWeight)
-      val otherCost = BigDecimal(other.planCost.card) * conf.joinReorderCardWeight +
-        BigDecimal(other.planCost.size) * (1 - conf.joinReorderCardWeight)
-      thisCost < otherCost
+      if (other.planCost.card == 0 || other.planCost.size == 0) {
+        false
+      } else {

Review comment:
       +1




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

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] cloud-fan commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-811627745


   The change LGTM. Can we re-generate the golden files to fix conflicts?


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

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] cloud-fan commented on a change in pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #32014:
URL: https://github.com/apache/spark/pull/32014#discussion_r604900965



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/CostBasedJoinReorder.scala
##########
@@ -349,11 +349,14 @@ object JoinReorderDP extends PredicateHelper with Logging {
     }
 
     def betterThan(other: JoinPlan, conf: SQLConf): Boolean = {
-      val thisCost = BigDecimal(this.planCost.card) * conf.joinReorderCardWeight +
-        BigDecimal(this.planCost.size) * (1 - conf.joinReorderCardWeight)
-      val otherCost = BigDecimal(other.planCost.card) * conf.joinReorderCardWeight +
-        BigDecimal(other.planCost.size) * (1 - conf.joinReorderCardWeight)
-      thisCost < otherCost
+      if (other.planCost.card == 0 || other.planCost.size == 0) {
+        false
+      } else {
+        val relativeRows = BigDecimal(this.planCost.card) / BigDecimal(other.planCost.card)
+        val relativeSize = BigDecimal(this.planCost.size) / BigDecimal(other.planCost.size)
+        Math.pow(relativeRows.doubleValue(), conf.joinReorderCardWeight) *
+          Math.pow(relativeSize.doubleValue(), 1 - conf.joinReorderCardWeight) < 1

Review comment:
       yea, after normalization the formula is still `row_count1 * size1 / (row_count2 * size2)`, so if one is `x` the other must be `1/x`.




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

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] SparkQA commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-811093920


   Kubernetes integration test status failure
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/41351/
   


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

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] SparkQA removed a comment on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-811686050


   **[Test build #136799 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/136799/testReport)** for PR 32014 at commit [`41b46a8`](https://github.com/apache/spark/commit/41b46a864dca21b303349971ab091c25c741fa37).


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

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] SparkQA commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-814251169


   **[Test build #136958 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/136958/testReport)** for PR 32014 at commit [`cdf7f08`](https://github.com/apache/spark/commit/cdf7f08bc7bdda6dd5abe542b3961f2bc4ac4057).


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

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 removed a comment on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-814440722


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/136958/
   


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

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] SparkQA commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-811445276


   Kubernetes integration test status failure
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/41363/
   


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

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 removed a comment on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-812479415


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/41429/
   


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

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] SparkQA commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-812428311


   **[Test build #136851 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/136851/testReport)** for PR 32014 at commit [`dc87250`](https://github.com/apache/spark/commit/dc872508d3dc46108b0332b8af5a9f08ea638265).


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

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 removed a comment on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-811558223


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/136780/
   


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

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] tanelk commented on a change in pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
tanelk commented on a change in pull request #32014:
URL: https://github.com/apache/spark/pull/32014#discussion_r604888377



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/CostBasedJoinReorder.scala
##########
@@ -349,11 +349,14 @@ object JoinReorderDP extends PredicateHelper with Logging {
     }
 
     def betterThan(other: JoinPlan, conf: SQLConf): Boolean = {
-      val thisCost = BigDecimal(this.planCost.card) * conf.joinReorderCardWeight +
-        BigDecimal(this.planCost.size) * (1 - conf.joinReorderCardWeight)
-      val otherCost = BigDecimal(other.planCost.card) * conf.joinReorderCardWeight +
-        BigDecimal(other.planCost.size) * (1 - conf.joinReorderCardWeight)
-      thisCost < otherCost
+      if (other.planCost.card == 0 || other.planCost.size == 0) {
+        false
+      } else {
+        val relativeRows = BigDecimal(this.planCost.card) / BigDecimal(other.planCost.card)
+        val relativeSize = BigDecimal(this.planCost.size) / BigDecimal(other.planCost.size)
+        Math.pow(relativeRows.doubleValue(), conf.joinReorderCardWeight) *
+          Math.pow(relativeSize.doubleValue(), 1 - conf.joinReorderCardWeight) < 1

Review comment:
       If I'm not mistaken, then, when the left side of the comparison is `x` for `A.betterThan(B)`, then for `B.betterThan(A)` it will be `1/x`. One of them will be greater than 1 and other smaller.




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

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] SparkQA commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-814248611






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

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] SparkQA commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-814322904


   **[Test build #136954 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/136954/testReport)** for PR 32014 at commit [`a7406e7`](https://github.com/apache/spark/commit/a7406e7ee9c628d08bc237e2ac688e08a7cb2bc6).
    * This patch passes all tests.
    * This patch **does not merge cleanly**.
    * This patch adds no public 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.

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 #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

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


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/136958/
   


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

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] cloud-fan commented on a change in pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #32014:
URL: https://github.com/apache/spark/pull/32014#discussion_r604882987



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/CostBasedJoinReorder.scala
##########
@@ -349,11 +349,14 @@ object JoinReorderDP extends PredicateHelper with Logging {
     }
 
     def betterThan(other: JoinPlan, conf: SQLConf): Boolean = {
-      val thisCost = BigDecimal(this.planCost.card) * conf.joinReorderCardWeight +
-        BigDecimal(this.planCost.size) * (1 - conf.joinReorderCardWeight)
-      val otherCost = BigDecimal(other.planCost.card) * conf.joinReorderCardWeight +
-        BigDecimal(other.planCost.size) * (1 - conf.joinReorderCardWeight)
-      thisCost < otherCost
+      if (other.planCost.card == 0 || other.planCost.size == 0) {
+        false
+      } else {
+        val relativeRows = BigDecimal(this.planCost.card) / BigDecimal(other.planCost.card)
+        val relativeSize = BigDecimal(this.planCost.size) / BigDecimal(other.planCost.size)
+        Math.pow(relativeRows.doubleValue(), conf.joinReorderCardWeight) *
+          Math.pow(relativeSize.doubleValue(), 1 - conf.joinReorderCardWeight) < 1

Review comment:
       is this symmetric?




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

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 #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

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


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/136768/
   


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

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] SparkQA commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-811542407


   **[Test build #136780 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/136780/testReport)** for PR 32014 at commit [`6c39602`](https://github.com/apache/spark/commit/6c39602bf8b2de234d797bbe4b4836cc6d3dc41b).
    * This patch passes all tests.
    * This patch merges cleanly.
    * This patch adds no public 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.

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 #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

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


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/136780/
   


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

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 removed a comment on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-812541588


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/136851/
   


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

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] SparkQA commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-811438678


   Kubernetes integration test starting
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/41363/
   


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

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] cloud-fan commented on a change in pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #32014:
URL: https://github.com/apache/spark/pull/32014#discussion_r604885266



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/CostBasedJoinReorder.scala
##########
@@ -349,11 +349,14 @@ object JoinReorderDP extends PredicateHelper with Logging {
     }
 
     def betterThan(other: JoinPlan, conf: SQLConf): Boolean = {
-      val thisCost = BigDecimal(this.planCost.card) * conf.joinReorderCardWeight +
-        BigDecimal(this.planCost.size) * (1 - conf.joinReorderCardWeight)
-      val otherCost = BigDecimal(other.planCost.card) * conf.joinReorderCardWeight +
-        BigDecimal(other.planCost.size) * (1 - conf.joinReorderCardWeight)
-      thisCost < otherCost
+      if (other.planCost.card == 0 || other.planCost.size == 0) {
+        false
+      } else {
+        val relativeRows = BigDecimal(this.planCost.card) / BigDecimal(other.planCost.card)
+        val relativeSize = BigDecimal(this.planCost.size) / BigDecimal(other.planCost.size)
+        Math.pow(relativeRows.doubleValue(), conf.joinReorderCardWeight) *
+          Math.pow(relativeSize.doubleValue(), 1 - conf.joinReorderCardWeight) < 1

Review comment:
       ah, it's kind of normalize the row count and bytes size with `Math.pow(_, m)` and `Math.pow(_, 1- m)`, then calculate the relative ratios and compare.




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

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] SparkQA commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-811257943


   **[Test build #136768 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/136768/testReport)** for PR 32014 at commit [`811c1c9`](https://github.com/apache/spark/commit/811c1c9f834f28afc6fe8fd9ae35719b9fb8b5d2).
    * This patch **fails Spark unit tests**.
    * This patch merges cleanly.
    * This patch adds no public 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.

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] SparkQA removed a comment on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-811392553


   **[Test build #136780 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/136780/testReport)** for PR 32014 at commit [`6c39602`](https://github.com/apache/spark/commit/6c39602bf8b2de234d797bbe4b4836cc6d3dc41b).


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

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 removed a comment on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-811691491


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/41381/
   


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

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] SparkQA commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-812540748


   **[Test build #136851 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/136851/testReport)** for PR 32014 at commit [`dc87250`](https://github.com/apache/spark/commit/dc872508d3dc46108b0332b8af5a9f08ea638265).
    * This patch passes all tests.
    * This patch merges cleanly.
    * This patch adds the following public classes _(experimental)_:
     * `case class SubtractTimestamps(`
     * `public class OrcArrayColumnVector extends OrcColumnVector `
     * `public class OrcAtomicColumnVector extends OrcColumnVector `
     * `public abstract class OrcColumnVector extends org.apache.spark.sql.vectorized.ColumnVector `
     * `class OrcColumnVectorUtils `
     * `public class OrcMapColumnVector extends OrcColumnVector `
     * `public class OrcStructColumnVector extends OrcColumnVector `


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

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] SparkQA removed a comment on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-812428311


   **[Test build #136851 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/136851/testReport)** for PR 32014 at commit [`dc87250`](https://github.com/apache/spark/commit/dc872508d3dc46108b0332b8af5a9f08ea638265).


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

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 #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

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


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/41535/
   


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

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] SparkQA commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-811687254


   Kubernetes integration test starting
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/41381/
   


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

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] SparkQA commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-811691474


   Kubernetes integration test status failure
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/41381/
   


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

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 #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

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


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/41381/
   


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

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] SparkQA commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-811087068


   Kubernetes integration test starting
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/41351/
   


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

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] tanelk commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
tanelk commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-811031262


   @wzhfy @maropu @HyukjinKwon and @cloud-fan 


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

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 removed a comment on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-811122664


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/41351/
   


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

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 removed a comment on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-811452200


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/41363/
   


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

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 removed a comment on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-814288643


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/41535/
   


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

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] SparkQA removed a comment on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-814198997


   **[Test build #136954 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/136954/testReport)** for PR 32014 at commit [`a7406e7`](https://github.com/apache/spark/commit/a7406e7ee9c628d08bc237e2ac688e08a7cb2bc6).


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

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] SparkQA commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-811392553


   **[Test build #136780 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/136780/testReport)** for PR 32014 at commit [`6c39602`](https://github.com/apache/spark/commit/6c39602bf8b2de234d797bbe4b4836cc6d3dc41b).


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

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] SparkQA removed a comment on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-814251169


   **[Test build #136958 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/136958/testReport)** for PR 32014 at commit [`cdf7f08`](https://github.com/apache/spark/commit/cdf7f08bc7bdda6dd5abe542b3961f2bc4ac4057).


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

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 removed a comment on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-811282398


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/136768/
   


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

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] cloud-fan commented on a change in pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #32014:
URL: https://github.com/apache/spark/pull/32014#discussion_r604879142



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/CostBasedJoinReorder.scala
##########
@@ -349,11 +349,14 @@ object JoinReorderDP extends PredicateHelper with Logging {
     }
 
     def betterThan(other: JoinPlan, conf: SQLConf): Boolean = {
-      val thisCost = BigDecimal(this.planCost.card) * conf.joinReorderCardWeight +
-        BigDecimal(this.planCost.size) * (1 - conf.joinReorderCardWeight)
-      val otherCost = BigDecimal(other.planCost.card) * conf.joinReorderCardWeight +
-        BigDecimal(other.planCost.size) * (1 - conf.joinReorderCardWeight)
-      thisCost < otherCost
+      if (other.planCost.card == 0 || other.planCost.size == 0) {
+        false
+      } else {
+        val relativeRows = BigDecimal(this.planCost.card) / BigDecimal(other.planCost.card)
+        val relativeSize = BigDecimal(this.planCost.size) / BigDecimal(other.planCost.size)
+        Math.pow(relativeRows.doubleValue(), conf.joinReorderCardWeight) *

Review comment:
       shall we update the config doc?




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

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] SparkQA commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-811038834


   **[Test build #136768 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/136768/testReport)** for PR 32014 at commit [`811c1c9`](https://github.com/apache/spark/commit/811c1c9f834f28afc6fe8fd9ae35719b9fb8b5d2).


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

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] SparkQA commented on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-812464987


   Kubernetes integration test starting
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/41429/
   


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

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 removed a comment on pull request #32014: [SPARK-34922][SQL] Use a relative cost comparison function in the CBO

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32014:
URL: https://github.com/apache/spark/pull/32014#issuecomment-814248677


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/41530/
   


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

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