Java Code Examples for org.apache.iceberg.transforms.Transforms#bucket()
The following examples show how to use
org.apache.iceberg.transforms.Transforms#bucket() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestFilteredScan.java From iceberg with Apache License 2.0 | 7 votes |
@BeforeClass public static void startSpark() { TestFilteredScan.spark = SparkSession.builder().master("local[2]").getOrCreate(); // define UDFs used by partition tests Transform<Long, Integer> bucket4 = Transforms.bucket(Types.LongType.get(), 4); spark.udf().register("bucket4", (UDF1<Long, Integer>) bucket4::apply, IntegerType$.MODULE$); Transform<Long, Integer> day = Transforms.day(Types.TimestampType.withZone()); spark.udf().register("ts_day", (UDF1<Timestamp, Integer>) timestamp -> day.apply((Long) fromJavaTimestamp(timestamp)), IntegerType$.MODULE$); Transform<Long, Integer> hour = Transforms.hour(Types.TimestampType.withZone()); spark.udf().register("ts_hour", (UDF1<Timestamp, Integer>) timestamp -> hour.apply((Long) fromJavaTimestamp(timestamp)), IntegerType$.MODULE$); spark.udf().register("data_ident", (UDF1<String, String>) data -> data, StringType$.MODULE$); spark.udf().register("id_ident", (UDF1<Long, Long>) id -> id, LongType$.MODULE$); }
Example 2
Source File: TestFilteredScan.java From iceberg with Apache License 2.0 | 6 votes |
@BeforeClass public static void startSpark() { TestFilteredScan.spark = SparkSession.builder().master("local[2]").getOrCreate(); // define UDFs used by partition tests Transform<Long, Integer> bucket4 = Transforms.bucket(Types.LongType.get(), 4); spark.udf().register("bucket4", (UDF1<Long, Integer>) bucket4::apply, IntegerType$.MODULE$); Transform<Long, Integer> day = Transforms.day(Types.TimestampType.withZone()); spark.udf().register("ts_day", (UDF1<Timestamp, Integer>) timestamp -> day.apply((Long) fromJavaTimestamp(timestamp)), IntegerType$.MODULE$); Transform<Long, Integer> hour = Transforms.hour(Types.TimestampType.withZone()); spark.udf().register("ts_hour", (UDF1<Timestamp, Integer>) timestamp -> hour.apply((Long) fromJavaTimestamp(timestamp)), IntegerType$.MODULE$); spark.udf().register("data_ident", (UDF1<String, String>) data -> data, StringType$.MODULE$); spark.udf().register("id_ident", (UDF1<Long, Long>) id -> id, LongType$.MODULE$); }
Example 3
Source File: Expressions.java From iceberg with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public static <T> UnboundTerm<T> bucket(String name, int numBuckets) { Transform<?, T> transform = (Transform<?, T>) Transforms.bucket(Types.StringType.get(), numBuckets); return new UnboundTransform<>(ref(name), transform); }