Home > Net >  Why can i not use greater than '>=' in Partition Parentheses in Spark SQL
Why can i not use greater than '>=' in Partition Parentheses in Spark SQL

Time:02-08

It was ok to use >= operator in Cloudera Hive sql, After migration to Databricks I am not able to use this operator in Partition Parentheses

ALTER TABLE tmprry.tmp_table DROP IF EXISTS PARTITION (log_date >= $LOG_DATE_EXECUTE_TWO_DAYS_AGO AND log_date <= $LOGDATE ) PURGE;

On the notebook it gives me error:

com.databricks.backend.common.rpc.DatabricksExceptions$SQLExecutionException: org.apache.spark.sql.catalyst.parser.ParseException: mismatched input '>=' expecting {')', ','}(line 2, pos 20)

== SQL == ALTER TABLE tmprry.tmp_table DROP IF EXISTS PARTITION (log_date >= 20220130 ) PURGE ---------------------------------------------------------------------------------------------------------^^^

CodePudding user response:

This supposedly happens because the partition column is a string and we are using comparison operators.

You can find the answer here

  •  Tags:  
  • Related