Skip to content

Instantly share code, notes, and snippets.

@mikeacjones
mikeacjones / Namespaces.dwl
Created May 19, 2020 12:48
Function for easily appending namespaces to all key:value pairs of an object. Full traversal, so objects in arrays too.
%dw 2.0
fun appendNamespace(data, nsSelector: (k: Key) -> Namespace | Null) =
data match {
case is Array -> data map appendNamespace($, nsSelector)
case is Object -> data mapObject do {
var ns0 = nsSelector($$)
---
if (ns0 != null) ns0#"$($$)": appendNamespace($, nsSelector)
else ($$): appendNamespace($, nsSelector)
@shivaram
shivaram / dataframe_example.R
Created June 2, 2015 23:54
DataFrame example in SparkR
# Download Spark 1.4 from http://spark.apache.org/downloads.html
#
# Download the nyc flights dataset as a CSV from https://s3-us-west-2.amazonaws.com/sparkr-data/nycflights13.csv
# Launch SparkR using
# ./bin/sparkR --packages com.databricks:spark-csv_2.10:1.0.3
# The SparkSQL context should already be created for you as sqlContext
sqlContext
# Java ref type org.apache.spark.sql.SQLContext id 1