Subject: Unable to write data from Spark into a Hive Managed table


Check your permissioning.

Can you do insert select from external table into Hive managed table
created by spark?

//
// Need to create and populate target ORC table transactioncodes_ll in
database accounts.in Hive
//
HiveContext.sql("use accounts")
//
// Drop and create table transactioncodes_ll
//
spark.sql("DROP TABLE IF EXISTS accounts.transactioncodes_ll")
var sqltext = ""
sqltext = """
CREATE TABLE accounts.transactioncodes_ll (
id                         Int
,transactiontype           String
,description               String
)
COMMENT 'from Hive external table'
STORED AS ORC
TBLPROPERTIES ( "orc.compress"="ZLIB" )
"""
HiveContext.sql(sqltext)
//
// Put data in Hive table. Clean up is already done
//
sqltext = """
INSERT INTO TABLE accounts.transactioncodes_ll
SELECT
          id
        , TRIM(transactiontype)
        , TRIM(description)
FROM <HIVE_EXTERNAL_TABLE>
"""
spark.sql(sqltext)

HTH

Dr Mich Talebzadeh

LinkedIn * https://www.linkedin.com/profile/view?id=AAEAAAAWh2gBxianrbJd6zP6AcPCCdOABUrV8Pw
<https://www.linkedin.com/profile/view?id=AAEAAAAWh2gBxianrbJd6zP6AcPCCdOABUrV8Pw>*

http://talebzadehmich.wordpress.com
*Disclaimer:* Use it at your own risk. Any and all responsibility for any
loss, damage or destruction of data or any other property which may arise
from relying on this email's technical content is explicitly disclaimed.
The author will in no case be liable for any monetary damages arising from
such loss, damage or destruction.
On Fri, 9 Aug 2019 at 12:04, Debabrata Ghosh <[EMAIL PROTECTED]> wrote: