Generate table as SQL
Presto:
with t1 as (select sequence(1,10) as c1)
select c from t1
CROSS JOIN UNNEST (c1) as t(c)
BigQuery:
with t1 as (select sequence(1,10) as c1)
select c from t1
CROSS JOIN UNNEST (c1) as t(c)
REPL based application will fail with initialization error of REPL if its jar file name has no extension '.jar' or '.zip'.
import scala.tools.nsc.Settings
import scala.tools.nsc.interpreter.shell.{ILoop, ShellConfig}
object ReplTestMain extends App {
println("test")
val settings = new Settings
settings.usejavacp.value = true
package test1 { | |
import com.databricks.spark.corenlp.functions._ | |
import org.apache.spark.sql.{DataFrame, SparkSession} | |
class Test(implicit spark: SparkSession) { | |
def run(df: DataFrame): DataFrame = { | |
import spark.implicits._ | |
val df2 = df.select(tokenize($"Text").as("word"), lemma($"Text").as("lemma"), pos($"Text").as("pos")).persist | |
df2.count | |
df2.unpersist() |
/** | |
* Generate Case class from DataFrame.schema | |
* | |
* val df:DataFrame = ... | |
* | |
* val s2cc = new Schema2CaseClass | |
* import s2cc.implicit._ | |
* | |
* println(s2cc.schemaToCaseClass(df.schema, "MyClass")) | |
* |
def snake2camel(s:String):String = s.toList.foldLeft(List.empty[Char]){ | |
case ('_'::xs, c) => c.toUpper::xs | |
case (xs, c) => c::xs | |
}.reverse.mkString("") | |