This file contains hidden or 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
| @$rs = sort { $a->{ 'SeqId' } <=> $b->{ 'SeqId' } } @$rs; | |
| foreach my $row ( @$rs ) { | |
| # dof stuff | |
| my $var = $row->{'col1'} | |
| } |
This file contains hidden or 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
| # ----------------------------------------------------------------------------- | |
| # the constructor | |
| # ----------------------------------------------------------------------------- | |
| sub new { | |
| my $class = shift; # Class name is in the first parameter | |
| $appConfig = ${ shift @_ } || { 'foo' => 'bar' ,} ; | |
| my $self = {}; # Anonymous hash reference holds instance attributes | |
| bless( $self, $class ); # Say: $self is a $class |
This file contains hidden or 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
| #------------------------------------------------------------------------------ | |
| # parse the single letter command line args | |
| #------------------------------------------------------------------------------ | |
| doParseCmdArgs(){ | |
| # traverse all the possible cmd args | |
| while getopts ":a:c:i:h:" opt; do | |
| case $opt in | |
| a) |
This file contains hidden or 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
| #------------------------------------------------------------------------------ | |
| # echo pass params and print them to a log file and terminal | |
| # with timestamp and $host_name and $0 PID | |
| # usage: | |
| # doLog "INFO some info message" | |
| # doLog "DEBUG some debug message" | |
| #------------------------------------------------------------------------------ | |
| doLog(){ | |
| type_of_msg=$(echo $*|cut -d" " -f1) |
This file contains hidden or 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 |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |