python - Mismatched Token Exception Hive Query -
i have single delimited string created python/spark function:
singlestringofdelimitednames= '|'.join([str(x.asdict().values()[0]) x in df3.collect()]) let's says 'dan|susie ann|bob.' when pass string hive udf created,
df2 = sqlcontext.sql("""select field1, field2 refinedtable createdhiveudf({0}, {1}, cast(field1 string), cast(field2 string)) """.format(percentage, singlestringofdelimitednames)) i'm getting mismatched token exception (26!=301). u"mismatched input 'ann' expecting ) near 'susie' in function specification.
what confuses me when hardcode "dan|susie ann|bob," shown below, working intended.
df2 = sqlcontext.sql("""select field1, field2 refinedtable createdhiveudf({0}, 'dan|susie ann|bob', cast(field1 string), cast(field2 string)) """.format(percentage)) i'm assuming i'm either using .format incorrectly, or have find different python/spark function create single delimited string column of names. if me understand mismatched token exception, , why hard coding above avoids issue, appreciate it.
aren't missing single quotes?
df2 = sqlcontext.sql("""select field1, field2 refinedtable createdhiveudf({0}, '{1}', cast(field1 string), cast(field2 string)) """.format(percentage, singlestringofdelimitednames))
Comments
Post a Comment