mirror of
https://github.com/apache/impala.git
synced 2026-01-27 06:10:53 -05:00
Previously Impala disallowed LOAD DATA and INSERT on S3. This patch functionally enables LOAD DATA and INSERT on S3 without making major changes for the sake of improving performance over S3. This patch also enables both INSERT and LOAD DATA between file systems. S3 does not support the rename operation, so the staged files in S3 are copied instead of renamed, which contributes to the slow performance on S3. The FinalizeSuccessfulInsert() function now does not make any underlying assumptions of the filesystem it is on and works across all supported filesystems. This is done by adding a full URI field to the base directory for a partition in the TInsertPartitionStatus. Also, the HdfsOp class now does not assume a single filesystem and gets connections to the filesystems based on the URI of the file it is operating on. Added a python S3 client called 'boto3' to access S3 from the python tests. A new class called S3Client is introduced which creates wrappers around the boto3 functions and have the same function signatures as PyWebHdfsClient by deriving from a base abstract class BaseFileSystem so that they can be interchangeably through a 'generic_client'. test_load.py is refactored to use this generic client. The ImpalaTestSuite setup creates a client according to the TARGET_FILESYSTEM environment variable and assigns it to the 'generic_client'. P.S: Currently, the test_load.py runs 4x slower on S3 than on HDFS. Performance needs to be improved in future patches. INSERT performance is slower than on HDFS too. This is mainly because of an extra copy that happens between staging and the final location of a file. However, larger INSERTs come closer to HDFS permformance than smaller inserts. ACLs are not taken care of for S3 in this patch. It is something that still needs to be discussed before implementing. Change-Id: I94e15ad67752dce21c9b7c1dced6e114905a942d Reviewed-on: http://gerrit.cloudera.org:8080/2574 Reviewed-by: Sailesh Mukil <sailesh@cloudera.com> Tested-by: Internal Jenkins
87 lines
3.7 KiB
Python
87 lines
3.7 KiB
Python
# Copyright (c) 2012 Cloudera, Inc. All rights reserved.
|
|
# Functional tests for LOAD DATA statements.
|
|
|
|
import os
|
|
import pytest
|
|
from tests.common.impala_test_suite import ImpalaTestSuite
|
|
from tests.common.test_dimensions import (
|
|
create_single_exec_option_dimension,
|
|
create_uncompressed_text_dimension)
|
|
from tests.common.skip import SkipIfLocal
|
|
from tests.util.filesystem_utils import WAREHOUSE
|
|
|
|
TEST_TBL_PART = "test_load"
|
|
TEST_TBL_NOPART = "test_load_nopart"
|
|
STAGING_PATH = 'test-warehouse/test_load_staging'
|
|
ALLTYPES_PATH = "test-warehouse/alltypes/year=2010/month=1/100101.txt"
|
|
MULTIAGG_PATH = 'test-warehouse/alltypesaggmultifiles/year=2010/month=1/day=1'
|
|
HIDDEN_FILES = ["{0}/3/.100101.txt".format(STAGING_PATH),
|
|
"{0}/3/_100101.txt".format(STAGING_PATH)]
|
|
|
|
@SkipIfLocal.hdfs_client
|
|
class TestLoadData(ImpalaTestSuite):
|
|
|
|
@classmethod
|
|
def get_workload(self):
|
|
return 'functional-query'
|
|
|
|
@classmethod
|
|
def add_test_dimensions(cls):
|
|
super(TestLoadData, cls).add_test_dimensions()
|
|
cls.TestMatrix.add_dimension(create_single_exec_option_dimension())
|
|
cls.TestMatrix.add_dimension(create_uncompressed_text_dimension(cls.get_workload()))
|
|
|
|
def _clean_test_tables(self):
|
|
self.client.execute("drop table if exists functional.{0}".format(TEST_TBL_NOPART))
|
|
self.client.execute("drop table if exists functional.{0}".format(TEST_TBL_PART))
|
|
self.filesystem_client.delete_file_dir(STAGING_PATH, recursive=True)
|
|
|
|
def teardown_method(self, method):
|
|
self._clean_test_tables()
|
|
|
|
def setup_method(self, method):
|
|
# Defensively clean the data dirs if they exist.
|
|
self._clean_test_tables()
|
|
|
|
# Create staging directories for load data inpath. The staging directory is laid out
|
|
# as follows:
|
|
# - It has 6 sub directories, numbered 1-6
|
|
# - The directories are populated with files from a subset of partitions in
|
|
# existing partitioned tables.
|
|
# - Sub Directories 1-4 have single files copied from alltypes/
|
|
# - Sub Directories 5-6 have multiple files (4) copied from alltypesaggmultifiles
|
|
# - Sub Directory 3 also has hidden files, in both supported formats.
|
|
# - All sub-dirs contain a hidden directory
|
|
for i in xrange(1, 6):
|
|
stagingDir = '{0}/{1}'.format(STAGING_PATH, i)
|
|
self.filesystem_client.make_dir(stagingDir, permission=777)
|
|
self.filesystem_client.make_dir('{0}/_hidden_dir'.format(stagingDir),
|
|
permission=777)
|
|
# Copy single file partitions from alltypes.
|
|
for i in xrange(1, 4):
|
|
self.filesystem_client.copy(ALLTYPES_PATH,
|
|
"{0}/{1}/100101.txt".format(STAGING_PATH, i))
|
|
# Copy multi file partitions from alltypesaggmultifiles.
|
|
file_names = self.filesystem_client.ls(MULTIAGG_PATH)
|
|
for i in xrange(4, 6):
|
|
for file_ in file_names:
|
|
self.filesystem_client.copy(
|
|
"{0}/{1}".format(MULTIAGG_PATH, file_),
|
|
'{0}/{1}/{2}'.format(STAGING_PATH, i, file_))
|
|
|
|
# Create two hidden files, with a leading . and _
|
|
for file_ in HIDDEN_FILES:
|
|
self.filesystem_client.copy(ALLTYPES_PATH, file_)
|
|
|
|
# Create both the test tables.
|
|
self.client.execute("create table functional.{0} like functional.alltypes"
|
|
" location '{1}/{0}'".format(TEST_TBL_PART, WAREHOUSE))
|
|
self.client.execute("create table functional.{0} like functional.alltypesnopart"
|
|
" location '{1}/{0}'".format(TEST_TBL_NOPART, WAREHOUSE))
|
|
|
|
def test_load(self, vector):
|
|
self.run_test_case('QueryTest/load', vector)
|
|
# The hidden files should not have been moved as part of the load operation.
|
|
for file_ in HIDDEN_FILES:
|
|
assert self.filesystem_client.exists(file_), "{0} does not exist".format(file_)
|