Median calculation in spark 1.6 Error: expected but identifier DIV found

I am trying to calculate median on latitude column based on group (destinationid and LocationID) column Scala Spark 1.6

Data in JSON looks like:

DESTINATION_ID,LOCATION_ID,LATITUDE
[ENSG00000257017,EAST_0000182,0.07092000000000001]
[ENSG00000257017,WEST_0001397,0.07092000000000001]
[ENSG00000181965,EAST_1001951,0.07056000000000001]
[ENSG00000146648,EAST_0000616,0.07092000000000001]
[ENSG00000111537,WEST_0001845,0.07092000000000001]
[ENSG00000103222,EAST_0000565,0.07056000000000001]
[ENSG00000118137,EAST_0000508,0.07092000000000001]
[ENSG00000112715,EAST_0000616,0.07092000000000001]
[ENSG00000108984,EAST_0000574,0.07056000000000001]
[ENSG00000159640,NORTH_797,0.07092000000000001]
[ENSG00000113522,NORTH_790,0.07056000000000001]
[ENSG00000133895,NORTH_562,0.07056000000000001]

Code

 > var ds = sqlContext.sql("""
>    SELECT DESTINATION_ID,LOCATION_ID, avg(LATITUDE) as median
> FROM ( SELECT DESTINATION_ID,LOCATION_ID, LATITUDE, rN, (CASE WHEN cN % 2 = 0 then (cN DIV 2) ELSE (cN DIV 2) + 1 end) as m1, (cN DIV 2) + 1 as m2
>         FROM (
>             SELECT DESTINATION_ID,LOCATION_ID, LATITUDE, row_number() OVER (PARTITION BY DESTINATION_ID,LOCATION_ID ORDER BY LATITUDE ) as rN, 
>         count(LATITUDE) OVER (PARTITION BY DESTINATION_ID,LOCATION_ID ) as cN
>             FROM people
>          ) s
>     ) r
> WHERE rN BETWEEN m1 and m2
> GROUP BY DESTINATION_ID,LOCATION_ID
> """)
> ```

Error:

> Exception in thread "main" java.lang.RuntimeException: [3.98] failure: ``)'' 
> expected but identifier DIV found

Please help . is there any better way to calculate median in spark 1.6

Forgive me, but how is this related to Gitlab?