Skip to content

Commit

Permalink
[native] Add support for ORC reader and add orc native tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wypb committed Jun 26, 2024
1 parent 1947f9e commit d8d1c28
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ dwio::common::FileFormat toVeloxFileFormat(
const presto::protocol::StorageFormat& format) {
if (format.inputFormat == "com.facebook.hive.orc.OrcInputFormat") {
return dwio::common::FileFormat::DWRF;
} else if (
format.inputFormat == "org.apache.hadoop.hive.ql.io.orc.OrcInputFormat") {
return dwio::common::FileFormat::ORC;
} else if (
format.inputFormat ==
"org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ private static void createTpcdsCallCenter(QueryRunner queryRunner, Session sessi
if (!queryRunner.tableExists(session, "call_center")) {
switch (storageFormat) {
case "PARQUET":
case "ORC":
queryRunner.execute(session, "CREATE TABLE call_center AS " +
"SELECT cc_call_center_sk, cast(cc_call_center_id as varchar) as cc_call_center_id, cc_rec_start_date, cc_rec_end_date, " +
" cc_closed_date_sk, cc_open_date_sk, cc_name, cc_class, cc_employees, cc_sq_ft, cast(cc_hours as varchar) as cc_hours, " +
Expand Down Expand Up @@ -164,6 +165,7 @@ private static void createTpcdsDateDim(QueryRunner queryRunner, Session session,
if (!queryRunner.tableExists(session, "date_dim")) {
switch (storageFormat) {
case "PARQUET":
case "ORC":
queryRunner.execute(session, "CREATE TABLE date_dim AS " +
"SELECT d_date_sk, cast(d_date_id as varchar) as d_date_id, d_date, " +
" d_month_seq, d_week_seq, d_quarter_seq, d_year, d_dow, d_moy, d_dom, d_qoy, d_fy_year, " +
Expand Down Expand Up @@ -221,6 +223,7 @@ private static void createTpcdsItem(QueryRunner queryRunner, Session session, St
if (!queryRunner.tableExists(session, "item")) {
switch (storageFormat) {
case "PARQUET":
case "ORC":
queryRunner.execute(session, "CREATE TABLE item AS " +
"SELECT i_item_sk, cast(i_item_id as varchar) as i_item_id, i_rec_start_date, i_rec_end_date, " +
" i_item_desc, i_current_price, i_wholesale_cost, i_brand_id, cast(i_brand as varchar) as i_brand, " +
Expand Down Expand Up @@ -284,6 +287,7 @@ private static void createTpcdsStore(QueryRunner queryRunner, Session session, S
if (!queryRunner.tableExists(session, "store")) {
switch (storageFormat) {
case "PARQUET":
case "ORC":
queryRunner.execute(session, "CREATE TABLE store AS " +
"SELECT s_store_sk, cast(s_store_id as varchar) as s_store_id, s_rec_start_date, s_rec_end_date, " +
" s_closed_date_sk, s_store_name, s_number_employees, s_floor_space, cast(s_hours as varchar) as s_hours, " +
Expand Down Expand Up @@ -353,6 +357,7 @@ private static void createTpcdsWebPage(QueryRunner queryRunner, Session session,
if (!queryRunner.tableExists(session, "web_page")) {
switch (storageFormat) {
case "PARQUET":
case "ORC":
queryRunner.execute(session, "CREATE TABLE web_page AS " +
"SELECT wp_web_page_sk, cast(wp_web_page_id as varchar) as wp_web_page_id, wp_rec_start_date, wp_rec_end_date, " +
" wp_creation_date_sk, wp_access_date_sk, cast(wp_autogen_flag as varchar) as wp_autogen_flag, wp_customer_sk, " +
Expand Down Expand Up @@ -392,6 +397,7 @@ private static void createTpcdsWebSite(QueryRunner queryRunner, Session session,
if (!queryRunner.tableExists(session, "web_site")) {
switch (storageFormat) {
case "PARQUET":
case "ORC":
queryRunner.execute(session, "CREATE TABLE web_site AS " +
"SELECT web_site_sk, cast(web_site_id as varchar) as web_site_id, web_rec_start_date, web_rec_end_date, web_name, " +
" web_open_date_sk, web_close_date_sk, web_class, web_manager, web_mkt_id, web_mkt_class, web_mkt_desc, web_market_manager, " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public static void createNationWithFormat(QueryRunner queryRunner, String storag
}

if (storageFormat.equals("ORC") && !queryRunner.tableExists(queryRunner.getDefaultSession(), "nation")) {
queryRunner.execute("CREATE TABLE nation AS SELECT * FROM tpch.tiny.nation");
queryRunner.execute("CREATE TABLE nation WITH (FORMAT = 'ORC') AS SELECT * FROM tpch.tiny.nation");
}

if (storageFormat.equals("JSON") && !queryRunner.tableExists(queryRunner.getDefaultSession(), "nation_json")) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.facebook.presto.nativeworker;

import com.facebook.presto.testing.ExpectedQueryRunner;
import com.facebook.presto.testing.QueryRunner;

public class TestPrestoNativeIcebergTpchQueriesOrcUsingThrift
extends AbstractTestNativeIcebergTpchQueries
{
@Override
protected QueryRunner createQueryRunner() throws Exception
{
return PrestoNativeQueryRunnerUtils.createNativeIcebergQueryRunner(true, "ORC");
}

@Override
protected ExpectedQueryRunner createExpectedQueryRunner() throws Exception
{
this.storageFormat = "ORC";
return PrestoNativeQueryRunnerUtils.createJavaIcebergQueryRunner("ORC");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import com.facebook.presto.testing.ExpectedQueryRunner;
import com.facebook.presto.testing.QueryRunner;

public class TestPrestoNativeIcebergTpchQueriesUsingThrift
public class TestPrestoNativeIcebergTpchQueriesParquetUsingThrift
extends AbstractTestNativeIcebergTpchQueries
{
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.facebook.presto.nativeworker;

import com.facebook.presto.testing.ExpectedQueryRunner;
import com.facebook.presto.testing.QueryRunner;
import org.testng.annotations.Test;

@Test(groups = {"orc"})
public class TestPrestoNativeTpchQueriesOrcUsingJSON
extends AbstractTestNativeTpchQueries
{
@Override
protected QueryRunner createQueryRunner() throws Exception
{
return PrestoNativeQueryRunnerUtils.createNativeQueryRunner(false, "ORC");
}

@Override
protected ExpectedQueryRunner createExpectedQueryRunner() throws Exception
{
return PrestoNativeQueryRunnerUtils.createJavaQueryRunner("ORC");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.facebook.presto.nativeworker;

import com.facebook.presto.testing.ExpectedQueryRunner;
import com.facebook.presto.testing.QueryRunner;

public class TestPrestoNativeTpchQueriesOrcUsingThrift
extends AbstractTestNativeTpchQueries
{
@Override
protected QueryRunner createQueryRunner() throws Exception
{
return PrestoNativeQueryRunnerUtils.createNativeQueryRunner(true, "ORC");
}

@Override
protected ExpectedQueryRunner createExpectedQueryRunner() throws Exception
{
return PrestoNativeQueryRunnerUtils.createJavaQueryRunner("ORC");
}
}

0 comments on commit d8d1c28

Please sign in to comment.