You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Takeshi Yamamuro (JIRA)" <ji...@apache.org> on 2018/05/10 06:31:00 UTC

[jira] [Commented] (SPARK-24233) union operation on read of dataframe does nor produce correct result

    [ https://issues.apache.org/jira/browse/SPARK-24233?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16469975#comment-16469975 ] 

Takeshi Yamamuro commented on SPARK-24233:
------------------------------------------

Can you simplify your query? Also, can you put the wrong/correct results that you got in your query?

> union operation on read of dataframe does nor produce correct result 
> ---------------------------------------------------------------------
>
>                 Key: SPARK-24233
>                 URL: https://issues.apache.org/jira/browse/SPARK-24233
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 2.1.0
>            Reporter: smohr003
>            Priority: Major
>
> I know that I can use wild card * to read all subfolders. But, I am trying to use .par and .schema to speed up the read process. 
> val absolutePath = "adl://datalakename.azuredatalakestore.net/testU/"
> Seq((1, "one"), (2, "two")).toDF("k", "v").write.mode("overwrite").parquet(absolutePath + "1")
> Seq((11, "one"), (22, "two")).toDF("k", "v").write.mode("overwrite").parquet(absolutePath + "2")
> Seq((111, "one"), (222, "two")).toDF("k", "v").write.mode("overwrite").parquet(absolutePath + "3")
> Seq((1111, "one"), (2222, "two")).toDF("k", "v").write.mode("overwrite").parquet(absolutePath + "4")
> Seq((2, "one"), (2, "two")).toDF("k", "v").write.mode("overwrite").parquet(absolutePath + "5")
>  
> import org.apache.hadoop.conf.Configuration
> import org.apache.hadoop.fs.\{FileSystem, Path}
> import java.net.URI
> def readDir(path: String): DataFrame = {
>  val fs = FileSystem.get(new URI(path), new Configuration())
>  val subDir = fs.listStatus(new Path(path)).map(i => i.getPath.toString)
>  var df = spark.read.parquet(subDir.head)
>  val dfSchema = df.schema
>  subDir.tail.par.foreach(p => df = df.union(spark.read.schema(dfSchema).parquet(p)).select(df.columns.head, df.columns.tail:_*))
>  df
> }
> val dfAll = readDir(absolutePath)
> dfAll.count
>  



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

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