This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// file: ~/.sbt/0.13/plugins/build.sbt | |
// or ~/.sbt/1.0/plugins/build.sbt | |
// or <<proj>> | |
// purpose: add jar utils useful for development, but not wanted to projects' build.sbt | |
// much better depts resolvement and fetching | |
// usage: sbt update | |
// https://github.com/coursier/coursier#why |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val pathAsStr: String = | |
Thread | |
.currentThread() | |
.getContextClassLoader() | |
.getResource("string/path/to/resource/dir/or/file") | |
.toString | |
// or | |
val strFilePath: String = getClass.getClassLoader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df.filter(df.col(X).isNotNull) | |
.filter(df.col(Y).isNotNull) | |
.filter(df.col(X).isNaN =!= true) | |
.filter(df.col(Y).isNaN =!= true) | |
.filter( | |
df.col(X) >= lit(minX) | |
&& df.col(X) <= lit(maxX) | |
&& df.col(Y) >= lit(minY) | |
&& df.col(Y) <= lit(maxY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val df = spark | |
.createDataFrame( | |
spark.sparkContext.parallelize( | |
Seq( | |
Row("row txt content", 1.0d, None, "2018-01-01", "2018-01-29T11:05:50") | |
)), | |
StructType( | |
Seq( | |
StructField("colOfStringType", StringType), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# usage: | |
# source zeppelin/sh/funcs/to-from-xls.sh | |
# export dir=<<path-to-the-root-dir-holding-the-csv-files-obs-recursive!!!!> | |
# toXls | |
# fromXls | |
# use BEFORE you wanto to open the files in xls | |
toXls(){ | |
set -u -o pipefail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add the "sep=," for xls to open quickly csv files | |
find $dir -type f -exec perl -pi -e 'print "sep=,\n" if $.==1' {} \; | |
# remove it | |
find $dir -type f -exec perl -pi -e '$_ = "" if $. == 1' {} \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val spark = SparkSession.builder().getOrCreate() | |
import spark.implicits._ | |
// format: off | |
// obs first and second row hardcoded vals are for "teaching" schema !!! | |
val ds = Seq( | |
// foo comments | |
(1,"foo",Some("bar"),Some(1850)) , | |
// bar comments | |
(2,"foo",None,None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.spark.rdd.RDD | |
import org.apache.spark.sql.DataFrame | |
import org.apache.spark.sql.Row | |
import org.apache.spark.sql.types.StructType | |
import org.apache.spark.sql.types.StructField | |
import org.apache.spark.sql.types.DoubleType | |
import org.apache.spark.sql.types.StringType | |
val objSchema: StructType = StructType( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.spark.sql.SparkSession | |
trait Phase { | |
implicit val spark: SparkSession = SparkSession.builder().getOrCreate() | |
def process(df: DataFrame): DataFrame | |
} | |
class Level1Phase ( cnf: Configuration) extends Phase { | |
override def process(df: DataFrame): DataFrame = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- DROP TABLE IF EXISTS item ; | |
SELECT 'create the "item" table' | |
; | |
CREATE TABLE item ( | |
guid UUID NOT NULL DEFAULT gen_random_uuid() | |
, level integer NULL | |
, seq integer NULL | |
, prio integer NULL | |
, name varchar (200) NOT NULL |