[ 
https://issues.apache.org/jira/browse/SPARK-25278?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jacek Laskowski updated SPARK-25278:
------------------------------------
    Description: 
When you use a view in a union multiple times (self-union), the {{number of 
output rows}} metric seems to be the correct {{number of output rows}} 
multiplied by the occurrences of the view, e.g.
{code:java}
scala> spark.version
res0: String = 2.3.1

val name = "demo_view"
sql(s"CREATE OR REPLACE VIEW $name AS VALUES 1,2")
assert(spark.catalog.tableExists(name))

val view = spark.table(name)

assert(view.count == 2)

view.union(view).show // gives 4 for every view, but should be 2
view.union(view).union(view).show // gives 6{code}
I think it's because {{View}} logical operator is a {{MultiInstanceRelation}} 
(and think other {{MultiInstanceRelations}} may also be affected).

  was:
When you use a view in a union multiple times (self-union), the {{number of 
output rows}} metric seems to be the correct {{number of output rows}} 
multiplied by the occurrences of the view, e.g.
{code:java}
scala> spark.version
res0: String = 2.3.1

val name = "demo_view"
sql(s"CREATE OR REPLACE VIEW $name AS VALUES 1,2")
assert(spark.catalog.tableExists(name))

val view = spark.table(name)

assert(view.count == 2)

view.union(view).show // gives 4 for every view, but should be 2
view.union(view).union(view).show // gives 6{code}
I think it's because {{View}} logical operator is a {{MultiInstanceRelation}} 
(and think other {{MultiInstanceRelation}}s may also be affected).


> Number of output rows metric of union of views is multiplied by their 
> occurrences
> ---------------------------------------------------------------------------------
>
>                 Key: SPARK-25278
>                 URL: https://issues.apache.org/jira/browse/SPARK-25278
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 2.3.1
>            Reporter: Jacek Laskowski
>            Priority: Major
>         Attachments: union-2-views.png, union-3-views.png
>
>
> When you use a view in a union multiple times (self-union), the {{number of 
> output rows}} metric seems to be the correct {{number of output rows}} 
> multiplied by the occurrences of the view, e.g.
> {code:java}
> scala> spark.version
> res0: String = 2.3.1
> val name = "demo_view"
> sql(s"CREATE OR REPLACE VIEW $name AS VALUES 1,2")
> assert(spark.catalog.tableExists(name))
> val view = spark.table(name)
> assert(view.count == 2)
> view.union(view).show // gives 4 for every view, but should be 2
> view.union(view).union(view).show // gives 6{code}
> I think it's because {{View}} logical operator is a {{MultiInstanceRelation}} 
> (and think other {{MultiInstanceRelations}} may also be affected).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to