Skip to content

Commit 43d42e8

Browse files
committed
Add TestPrestoNativeTvfFunctions
1 parent 294a811 commit 43d42e8

File tree

5 files changed

+101
-6
lines changed

5 files changed

+101
-6
lines changed

presto-hive/src/test/java/com/facebook/presto/hive/HiveQueryRunner.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import com.facebook.presto.tests.tpcds.TpcdsTableName;
3737
import com.facebook.presto.tpcds.TpcdsPlugin;
3838
import com.facebook.presto.tpch.TpchPlugin;
39-
import com.facebook.presto.tvf.TvfPlugin;
4039
import com.google.common.collect.ImmutableList;
4140
import com.google.common.collect.ImmutableMap;
4241
import com.google.common.collect.ImmutableSet;
@@ -244,9 +243,9 @@ public static DistributedQueryRunner createQueryRunner(
244243
metastore = externalMetastore.orElseGet(() -> getFileHiveMetastore(queryRunner));
245244

246245
queryRunner.installPlugin(new HivePlugin(HIVE_CATALOG, Optional.of(metastore)));
247-
248-
queryRunner.installCoordinatorPlugin(new TvfPlugin());
249-
queryRunner.loadTVFProvider("system");
246+
//
247+
// queryRunner.installCoordinatorPlugin(new TvfPlugin());
248+
// queryRunner.loadTVFProvider("system");
250249

251250
if (addJmxPlugin) {
252251
queryRunner.installPlugin(new JmxPlugin());

presto-native-execution/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,11 @@
300300
<artifactId>presto-jdbc</artifactId>
301301
<scope>test</scope>
302302
</dependency>
303+
<dependency>
304+
<groupId>com.facebook.presto</groupId>
305+
<artifactId>presto-native-tvf</artifactId>
306+
<scope>test</scope>
307+
</dependency>
303308
</dependencies>
304309

305310
<build>

presto-native-execution/presto_cpp/main/tvf/functions/Sequence.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,14 @@ class Sequence : public TableFunctionSplitProcessor {
196196

197197
static std::vector<TableSplitHandlePtr> getSplits(
198198
const TableFunctionHandlePtr& handle) {
199-
static const int64_t kMaxSteps = 10;
199+
static const int64_t kMaxSteps = 1000000;
200200
auto sequenceHandle =
201201
std::dynamic_pointer_cast<const SequenceHandle>(handle);
202202
auto start = sequenceHandle->start();
203203
auto stop = sequenceHandle->stop();
204204
auto step = sequenceHandle->step();
205205

206-
auto numSteps = (stop - start) / step;
206+
auto numSteps = (stop - start) / step + 1;
207207

208208
std::vector<TableSplitHandlePtr> splits = {};
209209
splits.reserve((numSteps/kMaxSteps) + 1);
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
package com.facebook.presto.nativeworker;
15+
16+
import com.facebook.presto.testing.QueryRunner;
17+
import com.facebook.presto.tests.AbstractTestQueryFramework;
18+
import com.facebook.presto.tvf.TvfPlugin;
19+
import org.testng.annotations.BeforeClass;
20+
import org.testng.annotations.Test;
21+
22+
import static com.facebook.presto.nativeworker.NativeQueryRunnerUtils.createRegion;
23+
24+
@Test
25+
public abstract class AbstractTestNativeTvfFunctions
26+
extends AbstractTestQueryFramework
27+
{
28+
@BeforeClass
29+
@Override
30+
public void init() throws Exception
31+
{
32+
super.init();
33+
getQueryRunner().installCoordinatorPlugin(new TvfPlugin());
34+
getQueryRunner().loadTVFProvider("system");
35+
}
36+
37+
@Override
38+
protected void createTables()
39+
{
40+
createRegion((QueryRunner) getExpectedQueryRunner());
41+
}
42+
43+
@Test
44+
public void testSequence()
45+
{
46+
assertQuery("SELECT * FROM TABLE(sequence( start => 20, stop => 100, step => 5))");
47+
}
48+
49+
@Test
50+
public void testExcludeColumns()
51+
{
52+
assertQuery("SELECT * FROM TABLE(exclude_columns(input => TABLE(region), columns => DESCRIPTOR(regionkey, comment)))");
53+
}
54+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
package com.facebook.presto.nativeworker;
15+
16+
import com.facebook.presto.testing.ExpectedQueryRunner;
17+
import com.facebook.presto.testing.QueryRunner;
18+
19+
public class TestPrestoNativeTvfFunctions
20+
extends AbstractTestNativeTvfFunctions
21+
{
22+
@Override
23+
protected QueryRunner createQueryRunner() throws Exception
24+
{
25+
return PrestoNativeQueryRunnerUtils.nativeHiveQueryRunnerBuilder()
26+
.setAddStorageFormatToPath(true)
27+
.build();
28+
}
29+
30+
@Override
31+
protected ExpectedQueryRunner createExpectedQueryRunner() throws Exception
32+
{
33+
return PrestoNativeQueryRunnerUtils.javaHiveQueryRunnerBuilder()
34+
.setAddStorageFormatToPath(true)
35+
.build();
36+
}
37+
}

0 commit comments

Comments
 (0)