title: What is 'no viable alternative at input' for spark sql?
body: <p>I have a DF that has <code>startTimeUnix</code> column (of type Number in Mongo) that contains epoch timestamps. I want to query the DF on this column but I want to pass EST datetime. I went through multiple hoops to test the following on spark-shell:</p>
  
  <pre><code>val df = Seq(("1", "1523937600000"), ("2", "1523941200000"),("3","1524024000000")).toDF("id", "unix")
  
  df.filter($"unix" &gt; java.time.ZonedDateTime.parse("04/17/2018 01:00:00", java.time.format.DateTimeFormatter.ofPattern ("MM/dd/yyyy HH:mm:ss").withZone ( java.time.ZoneId.of("America/New_York"))).toEpochSecond()*1000).collect()
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <pre><code>= Array([3,1524024000000])
  </code></pre>
  
  <p>Since the java.time functions are working, I am passing the same to <code>spark-submit</code> where while retrieving the data from Mongo, the filter query goes like:</p>
  
  <p><strong>startTimeUnix &lt;</strong> (java.time.ZonedDateTime.parse(${LT}, java.time.format.DateTimeFormatter.ofPattern('MM/dd/yyyyHHmmss').withZone(java.time.ZoneId.of('America/New_York'))).toEpochSecond()*1000) <strong>AND startTimeUnix ></strong> (java.time.ZonedDateTime.parse(${GT}, java.time.format.DateTimeFormatter.ofPattern('MM/dd/yyyyHHmmss').withZone(java.time.ZoneId.of('America/New_York'))).toEpochSecond()*1000)`</p>
  
  <p><strong>However, I keep getting following error:</strong></p>
  
  <blockquote>
    <p>Caused by: org.apache.spark.sql.catalyst.parser.ParseException:
    no viable alternative at input '(java.time.ZonedDateTime.parse(04/18/2018000000, java.time.format.DateTimeFormatter.ofPattern('MM/dd/yyyyHHmmss').withZone('(line 1, pos 138)
    == SQL ==
    startTimeUnix &lt; (java.time.ZonedDateTime.parse(04/18/2018000000, java.time.format.DateTimeFormatter.ofPattern('MM/dd/yyyyHHmmss').withZone(java.time.ZoneId.of('America/New_York'))).toEpochSecond()*1000).toString() AND startTimeUnix > (java.time.ZonedDateTime.parse(04/17/2018000000, java.time.format.DateTimeFormatter.ofPattern('MM/dd/yyyyHHmmss').withZone(java.time.ZoneId.of('America/New_York'))).toEpochSecond()*1000).toString()
    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.parseExpression(ParseDriver.scala:43)
        at org.apache.spark.sql.Dataset.filter(Dataset.scala:1315)</p>
  </blockquote>
  
  <p>Somewhere it said the error meant mis-matched data type. I tried applying toString to the output of date conversion with no luck.</p>