You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Paul Wu (JIRA)" <ji...@apache.org> on 2018/01/23 17:27:00 UTC
[jira] [Created] (SPARK-23193) Insert into Spark Table cannot
specify column names
Paul Wu created SPARK-23193:
-------------------------------
Summary: Insert into Spark Table cannot specify column names
Key: SPARK-23193
URL: https://issues.apache.org/jira/browse/SPARK-23193
Project: Spark
Issue Type: Bug
Components: SQL
Affects Versions: 2.2.1
Reporter: Paul Wu
The following code shows the insert statement cannot specify the column names. The error is
{{insert into aaa (age, name) values (12, 'nn')}}
{{-----------------^^^}}
{{ at org.apache.spark.sql.catalyst.parser.ParseException.withCommand(ParseDriver.scala:217)}}
{{ at org.apache.spark.sql.catalyst.parser.AbstractSqlParser.parse(ParseDriver.scala:114)}}
{{ at org.apache.spark.sql.execution.SparkSqlParser.parse(SparkSqlParser.scala:48)}}
{{ at org.apache.spark.sql.catalyst.parser.AbstractSqlParser.parsePlan(ParseDriver.scala:68)}}
{{ at org.apache.spark.sql.SparkSession.sql(SparkSession.scala:632)}}
{{ at com.---.iqi.spk.TestInsert.main(TestInsert.java:75)}}
{{public class TestInsert {}}
{{ public static final SparkSession spark}}
{{ = SparkSession.builder()}}
{{ .config("spark.sql.warehouse.dir", "file:///temp")}}
{{ .config("spark.driver.memory", "5g")}}
{{ .enableHiveSupport()}}
{{ .master("local[*]").appName("Spark2JdbcDs").getOrCreate();}}
{{ }}
{{ public static class Person implements Serializable {}}
{{ private String name;}}
{{ private int age;}}
{{ public String getName() {}}
{{ return name;}}
{{ }}}
{{ public void setName(String name) {}}
{{ this.name = name;}}
{{ }}}
{{ public int getAge() {}}
{{ return age;}}
{{ }}}
{{ public void setAge(int age) {}}
{{ this.age = age;}}
{{ }}}
{{ }}}
{{ public static void main(String[] args) throws Exception {}}
{{ // Create an instance of a Bean class}}
{{ Person person = new Person();}}
{{ person.setName("Andy");}}
{{ person.setAge(32);}}
{{// Encoders are created for Java beans}}
{{ Encoder<Person> personEncoder = Encoders.bean(Person.class);}}
{{ Dataset<Person> javaBeanDS = spark.createDataset(}}
{{ Collections.singletonList(person),}}
{{ personEncoder}}
{{ );}}
{{ javaBeanDS.show();}}
{{ javaBeanDS.createTempView("Abc");}}
{{ spark.sql("drop table aaa");}}
{{ spark.sql("create table aaa as select * from abc");}}
{{ spark.sql("insert into aaa values (12, 'nn')");}}
{{ spark.sql("select * from aaa").show();}}
{{ spark.sql("insert into aaa (age, name) values (12, 'nn')");}}
{{ spark.sql("select * from aaa").show();}}
{{ }}
{{ spark.close();}}
{{ }}
{{ }}}
{{}}}
--
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