Skip to content

Instantly share code, notes, and snippets.

@cmerrick
Created October 21, 2015 01:37
Show Gist options
  • Save cmerrick/83380aee9892a2ea7ae8 to your computer and use it in GitHub Desktop.
Save cmerrick/83380aee9892a2ea7ae8 to your computer and use it in GitHub Desktop.
TPC-H json and avro wrangling
BEGIN {FS = "|"}
{print "{" \
"\"l_orderkey\": " $1 ", " \
"\"l_partkey\": " $2 ", " \
"\"l_suppkey\": " $3 ", " \
"\"l_linenumber\": " $4 ", " \
"\"l_quantity\": " $5 ", " \
"\"l_extendedprice\": " $6 ", " \
"\"l_discount\": " $7 ", " \
"\"l_tax\": " $8 ", " \
"\"l_returnflag\": \"" $9 "\", " \
"\"l_linestatus\": \"" $10 "\", " \
"\"l_shipdate\": \"" $11 "\", " \
"\"l_commitdate\": \"" $12 "\", " \
"\"l_receiptdate\": \"" $13 "\", " \
"\"l_shipinstruct\": \"" $14 "\", " \
"\"l_shipmode\": \"" $15 "\", " \
"\"l_comment\": \"" $16 "\"" \
"}"
}
{"namespace": "rjm.db-benchmark",
"type": "record",
"name": "lineitem",
"fields": [
{"name": "l_orderkey", "type": "int"},
{"name": "l_partkey", "type": "int"},
{"name": "l_suppkey", "type": "int"},
{"name": "l_linenumber", "type": "int"},
{"name": "l_quantity", "type": "float"},
{"name": "l_extendedprice", "type": "float"},
{"name": "l_discount", "type": "float"},
{"name": "l_tax", "type": "float"},
{"name": "l_returnflag", "type": "string"},
{"name": "l_linestatus", "type": "string"},
{"name": "l_shipdate", "type": "string"},
{"name": "l_commitdate", "type": "string"},
{"name": "l_receiptdate", "type": "string"},
{"name": "l_shipinstruct", "type": "string"},
{"name": "l_shipmode", "type": "string"},
{"name": "l_comment", "type": "string"}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment