Hi,

Iv created a simple example using the withColumn method but throws an
error. Try:

val df = List(
  (1,1),
  (1,1),
  (1,2),
  (2,2)
).toDF("col1", "col2")

val index_col = sqlContext.range( df.count() ).col("id")
val df_with_index = df.withColumn("index", index_col)

The error I get is:

org.apache.spark.sql.AnalysisException: resolved attribute(s) id#76L
missing from col1#69,col2#70 in operator !Project [col1#69,col2#70,id#76L
AS index#77L];

Is this the right to add an ID column or is this a bug?

Many thanks.
Josh

Reply via email to