protected TestDateTimeFunctionsBase(boolean legacyTimestamp) { super(testSessionBuilder() .setSystemProperty("legacy_timestamp", String.valueOf(legacyTimestamp)) .setTimeZoneKey(TIME_ZONE_KEY) .setStartTime(new DateTime(2017, 4, 1, 12, 34, 56, 789, UTC_TIME_ZONE).getMillis()) .build()); TIMESTAMP = legacyTimestamp ? LEGACY_TIMESTAMP : NEW_TIMESTAMP; }
@Test public void testComplexCast() { Session session = Session.builder(getSession()) .setSystemProperty(SystemSessionProperties.OPTIMIZE_DISTINCT_AGGREGATIONS, "true") .build(); // This is optimized using CAST(null AS interval day to second) which may be problematic to deserialize on worker assertQuery(session, "WITH t(a, b) AS (VALUES (1, INTERVAL '1' SECOND)) " + "SELECT count(DISTINCT a), CAST(max(b) AS VARCHAR) FROM t", "VALUES (1, '0 00:00:01.000')"); } }
public MockQueryExecution(long memoryUsage, String queryId, int priority, Duration cpuUsage) { this.memoryUsage = succinctBytes(memoryUsage); this.cpuUsage = cpuUsage; this.session = testSessionBuilder() .setSystemProperty(QUERY_PRIORITY, String.valueOf(priority)) .build(); this.resourceGroupId = Optional.empty(); this.queryId = new QueryId(queryId); }
@Setup public void setup() { Session session = testSessionBuilder() .setSystemProperty("join_reordering_strategy", joinReorderingStrategy) .setSystemProperty("join_distribution_type", "AUTOMATIC") .setCatalog("tpch") .setSchema("tiny") .build(); queryRunner = new LocalQueryRunner(session); queryRunner.createCatalog("tpch", new TpchConnectorFactory(1), ImmutableMap.of()); }
@Test public void testDistributedDistanceQuery() { assertUpdate(format("CREATE TABLE distance_partitioning AS SELECT spatial_partitioning(ST_Point(x, y)) as v " + "FROM (VALUES (0, 0, '0_0'), (1, 0, '1_0'), (3, 0, '3_0'), (10, 0, '10_0')) as a (x, y, name)"), 1); Session session = Session.builder(getSession()) .setSystemProperty(SPATIAL_PARTITIONING_TABLE_NAME, "distance_partitioning") .build(); testDistanceQuery(session); }
private Session getParallelWriteSession() { return Session.builder(getSession()) .setSystemProperty("task_writer_count", "4") .build(); }
protected TestTimestampBase(boolean legacyTimestamp) { super(testSessionBuilder() .setSystemProperty("legacy_timestamp", String.valueOf(legacyTimestamp)) .setTimeZoneKey(TIME_ZONE_KEY) .build()); }
protected TestDateTimeOperatorsBase(boolean legacyTimestamp) { super(testSessionBuilder() .setSystemProperty("legacy_timestamp", String.valueOf(legacyTimestamp)) .setTimeZoneKey(TIME_ZONE_KEY) .build()); }
protected Session noJoinReordering() { return Session.builder(getSession()) .setSystemProperty(JOIN_REORDERING_STRATEGY, JoinReorderingStrategy.NONE.name()) .setSystemProperty(JOIN_DISTRIBUTION_TYPE, JoinDistributionType.PARTITIONED.name()) .build(); } }
public RuleAssert setSystemProperty(String key, String value) { return withSession(Session.builder(session) .setSystemProperty(key, value) .build()); }
@Test public void tesDistributedSpatialJoinIntersects() { assertUpdate(format("CREATE TABLE intersects_partitioning AS " + "SELECT spatial_partitioning(ST_GeometryFromText(wkt)) as v " + "FROM (%s) as a (wkt, name, id)", POLYGONS_SQL), 1); Session session = Session.builder(getSession()) .setSystemProperty(SPATIAL_PARTITIONING_TABLE_NAME, "intersects_partitioning") .build(); testSpatialJoinIntersects(session); }
private Session singleNodeOutput(boolean force) { return Session.builder(this.getQueryRunner().getDefaultSession()) .setSystemProperty(FORCE_SINGLE_NODE_OUTPUT, Boolean.toString(force)) .build(); } }
protected TestTimeWithTimeZoneBase(boolean legacyTimestamp) { super(testSessionBuilder() .setSystemProperty("legacy_timestamp", String.valueOf(legacyTimestamp)) .setTimeZoneKey(getTimeZoneKey("+06:09")) .build()); }
public TestTimeBase(boolean legacyTimestamp) { super(testSessionBuilder() .setSystemProperty("legacy_timestamp", String.valueOf(legacyTimestamp)) .setTimeZoneKey(TIME_ZONE_KEY) .build()); }
public TestDictionaryAggregation() { super(() -> { LocalQueryRunner queryRunner = new LocalQueryRunner(testSessionBuilder() .setSystemProperty(DICTIONARY_AGGREGATION, "true") .setSystemProperty(REORDER_JOINS, "false") // no JOIN reordering .build()); queryRunner.createCatalog("tpch", new TpchConnectorFactory(1), ImmutableMap.of()); return queryRunner; }); }
private Session withSpatialPartitioning(String tableName) { return Session.builder(this.getQueryRunner().getDefaultSession()) .setSystemProperty(SPATIAL_PARTITIONING_TABLE_NAME, tableName) .build(); } }
protected TestDateBase(boolean legacyTimestamp) { super(testSessionBuilder() .setSystemProperty("legacy_timestamp", String.valueOf(legacyTimestamp)) .setTimeZoneKey(TIME_ZONE_KEY) .build()); }
@BeforeClass public void setupClass() { defaultFilterTester = new StatsCalculatorTester( testSessionBuilder() .setSystemProperty("default_filter_factor_enabled", "true") .build()); }
@Test public void testDistributedSpatialJoinContains() { assertUpdate(format("CREATE TABLE contains_partitioning AS " + "SELECT spatial_partitioning(ST_GeometryFromText(wkt)) as v " + "FROM (%s) as a (wkt, name, id)", POLYGONS_SQL), 1); Session session = Session.builder(getSession()) .setSystemProperty(SPATIAL_PARTITIONING_TABLE_NAME, "contains_partitioning") .build(); testSpatialJoinContains(session); }
private void testTimeRepresentationOnDate(DateTime date, String timeLiteral, Type expectedType, Object expected) { Session localSession = testSessionBuilder() .setTimeZoneKey(getTimeZoneKey("America/Los_Angeles")) .setStartTime(date.getMillis()) .setSystemProperty("legacy_timestamp", "false") .build(); try (FunctionAssertions localAssertions = new FunctionAssertions(localSession)) { localAssertions.assertFunction(timeLiteral, expectedType, expected); localAssertions.assertFunctionString(timeLiteral, expectedType, valueFromLiteral(timeLiteral)); } }