[ https://issues.apache.org/jira/browse/SPARK-17646?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Josh Rosen resolved SPARK-17646. -------------------------------- Resolution: Not A Problem Yep, this is the intended behavior. From the Scaladoc: {code} /** * Creates a new [[StructType]] by adding a new nullable field with no metadata. * * val struct = (new StructType) * .add("a", IntegerType) * .add("b", LongType) * .add("c", StringType) */ def add(name: String, dataType: DataType): StructType = { StructType(fields :+ new StructField(name, dataType, nullable = true, Metadata.empty)) } {code} > SparkType::add method does not work in 2.0.0 (in Java) > ------------------------------------------------------ > > Key: SPARK-17646 > URL: https://issues.apache.org/jira/browse/SPARK-17646 > Project: Spark > Issue Type: Bug > Components: Java API > Environment: spark-sql_2.11 > version 2.0.0 > Java 8 > Reporter: Pawel Skorupinski > Priority: Minor > > Add methods do not work: > StructType inputStructure = new StructType(); > inputStructure.add("b",new IntegerType(),false); > inputStructure.add("a","string"); > System.err.println(inputStructure.sql()); > >> STRUCT<> > System.err.println(inputStructure.length()); > >> 0 > Constructor is working: > StructField [] structFields = new StructField[1]; > structFields[0] = new StructField("a",new StringType(),false,null); > inputStructure = new StructType(structFields); > System.err.println(inputStructure.sql()); > >> STRUCT<`a`: STRING> > System.err.println(inputStructure.length()); > >> 1 -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org