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

Ruslan Dautkhanov commented on SPARK-21488:
-------------------------------------------

[~zsxwing] any chance this can be added to Spark 3.0?

I can try to create a PR for this.. many of our users are still reporting this 
as relevant 
as this would streamline their code in many places . 

We always have a good mix of Spark SQL and Spark API calls in many places,
and this would be a huge win for code readability. 

 

> Make saveAsTable() and createOrReplaceTempView() return dataframe of created 
> table/ created view
> ------------------------------------------------------------------------------------------------
>
>                 Key: SPARK-21488
>                 URL: https://issues.apache.org/jira/browse/SPARK-21488
>             Project: Spark
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 2.2.0
>            Reporter: Ruslan Dautkhanov
>            Priority: Minor
>              Labels: bulk-closed
>
> It would be great to make saveAsTable() return dataframe of created table, 
> so you could pipe result further as for example
> {code}
> mv_table_df = (sqlc.sql('''
>         SELECT ...
>         FROM 
>     ''')
>         .write.format("parquet").mode("overwrite")
>         .saveAsTable('test.parquet_table')
>         .createOrReplaceTempView('mv_table')
>     )
> {code}
> ... Above code returns now expectedly:
> {noformat}
> AttributeError: 'NoneType' object has no attribute 'createOrReplaceTempView'
> {noformat}
> If this is implemented, we can skip a step like
> {code}
> sqlc.sql('SELECT * FROM 
> test.parquet_table').createOrReplaceTempView('mv_table')
> {code}
> We have this pattern very frequently. 
> Further improvement can be made if createOrReplaceTempView also returns 
> dataframe object, so in one pipeline of functions 
> we can 
> - create an external table 
> - create a dataframe reference to this newly created for SparkSQL and as a 
> Spark variable.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to