3 ms·
I can see why you'd want to keep it non-Java and simple. I will admit that I am biased since I work with Spark all day, but I think you'll eventually want to wr
by zten 10y ago
I can see why you'd want to keep it non-Java and simple. I will admit that I am biased since I work with Spark all day, but I think you'll eventually want to write a query where you wish you had Spark SQL or could manipulate it as a Spark RDD.
Spark actually isn't too painful for this because you can run it locally in a single process. It is not exactly as elegant as the UNIX way you outline in your second example, but it isn't as horrifying as submitting a YARN job or spinning up a cluster.
In spark-shell:
// Skip this conversion if you're just running one query. Do it if you're running many.
spark.read.json(input paths).write.parquet("/target/path")
spark.read.parquet("/target/path").createOrReplaceTempView("logs")
spark.sql("select count(distinct src) from logs where dport = 23").show()
The incremental conversion of your JSON data set to Parquet will be a little bit more annoying to write in Scala than the above example, but is very much doable. There is also a small amount of overhead with the first spark.read.parquet, but it's faster on a local data source than it is against something like S3.
- justinsaccount 10y agoYeah.. I agree. It's not really that I don't want to use spark, it's more that I don't want to have to use spark just to convert some data files. If I can write a short tool that wraps the spark.read.json(input paths).write.parquet("/target/path") As spark.read.json(argv[1]).write.parquet(argv[2]) and then use it like json_to_parquet /logs/json/2016-12-28.gz /logs/parquet/2016-12-28 or something, that would work. I just wish there were some more cli friendly tools for the cases where the grep | cut | sort pipeline works, but you'd like to just make it a bit more efficient.