복붙노트

[HADOOP] 여러 장소를 동일한 하이브 외부 테이블로 지정할 수 있습니까?

HADOOP

여러 장소를 동일한 하이브 외부 테이블로 지정할 수 있습니까?

여러 달 데이터를 동시에 처리해야합니다. 따라서 여러 폴더를 외부 테이블로 지정하는 옵션이 있습니까? 예 : 외부 테이블 logdata (col1 문자열, col2 문자열 ........) 위치 생성 s3 : // logdata / april, s3 : // logdata / march

해결법

  1. ==============================

    1.간단한 대답 : 아니요. 생성하는 동안 Hive 외부 테이블의 위치는 고유해야합니다. 이는 메타 스토어가 테이블의 위치를 ​​이해하기 위해 필요합니다.

    간단한 대답 : 아니요. 생성하는 동안 Hive 외부 테이블의 위치는 고유해야합니다. 이는 메타 스토어가 테이블의 위치를 ​​이해하기 위해 필요합니다.

    즉, 파티션을 사용하여 벗어날 수 있습니다. 월별로 나눈 이후 궁극적으로 원하는 것으로 보이는 각 파티션의 위치를 ​​지정할 수 있습니다.

    따라서 다음과 같이 테이블을 만드십시오.

    create external table logdata(col1 string, col2 string) partitioned by (month string) location 's3://logdata'
    

    그런 다음 다음과 같이 파티션을 추가 할 수 있습니다.

    alter table logdata add partition(month='april') location 's3://logdata/april'
    

    매월이 작업을 수행하면 원하는 파티션을 지정하여 테이블을 쿼리 할 수 ​​있으며 Hive는 실제로 데이터를 원하는 디렉토리 만 찾습니다 (예 : 4 월과 6 월만 처리하는 경우 Hive는 그렇지 않습니다) 부하가 발생할 수 있음)

  2. ==============================

    2.시나리오를 확인했습니다. 여러 위치를 활성화하기 위해 여러로드 inpath 문을 사용하여이를 달성 할 수 있다고 생각합니다. 아래는 내가 수행 한 테스트를 위해 취한 단계입니다.

    시나리오를 확인했습니다. 여러 위치를 활성화하기 위해 여러로드 inpath 문을 사용하여이를 달성 할 수 있다고 생각합니다. 아래는 내가 수행 한 테스트를 위해 취한 단계입니다.

    hive> create external table xxx (uid int, name string, dept string) row format delimited fields terminated by '\t' stored as textfile;
    hive> load data inpath '/input/tmp/user_bckt' into table xxx;
    hive> load data inpath '/input/user_bckt' into table xxx;
    hive> select count(*) from xxx;
    10
    hive> select * from xxx;
    1   ankur   abinitio
    2   lokesh  cloud
    3   yadav   network
    4   sahu    td
    5   ankit   data
    1   ankur   abinitio
    2   lokesh  cloud
    3   yadav   network
    4   sahu    td
    5   ankit   data
    

    이것이 효과가없는 경우 알려주십시오

    편집 : 방금 데이터가 원래 위치에 남아있는 외부 테이블 데이터 개념과 반대로이 경우 데이터가 하이브웨어 하우스로 이동하고 있음을 확인했습니다.

    hduser@hadoopnn:~$ hls /input/tmp
    DEPRECATED: Use of this script to execute hdfs command is deprecated.
    Instead use the hdfs command for it.
    
    14/10/05 14:47:18 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
    Found 2 items
    -rw-r--r--   1 hduser hadoop         93 2014-10-04 18:54 /input/tmp/dept_bckt
    -rw-r--r--   1 hduser hadoop         71 2014-10-04 18:54 /input/tmp/user_bckt
    hduser@hadoopnn:~$ hcp /input/tmp/user_bckt /input/user_bckt
    DEPRECATED: Use of this script to execute hdfs command is deprecated.
    Instead use the hdfs command for it.
    
    14/10/05 14:47:44 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
    hduser@hadoopnn:~$ logout
    Connection to nn closed.
    hduser@hadoopdn2:~$ hls /input/tmp/
    DEPRECATED: Use of this script to execute hdfs command is deprecated.
    Instead use the hdfs command for it.
    
    14/10/05 15:05:47 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
    Found 1 items
    -rw-r--r--   1 hduser hadoop         93 2014-10-04 18:54 /input/tmp/dept_bckt
    hduser@hadoopdn2:~$ hls /hive/wh/xxx
    DEPRECATED: Use of this script to execute hdfs command is deprecated.
    Instead use the hdfs command for it.
    
    14/10/05 15:21:54 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
    Found 2 items
    -rw-r--r--   1 hduser hadoop         71 2014-10-04 18:54 /hive/wh/xxx/user_bckt
    -rw-r--r--   1 hduser hadoop         71 2014-10-05 14:47 /hive/wh/xxx/user_bckt_copy_1
    

    나는 현재 여기서 문제를 조사하고 있으며 일단 완료되면 다시 돌아올 것입니다.

  3. ==============================

    3.아니요, 위치는 단일 디렉토리 여야합니다. 그러나 여러 디렉토리를 가리 키도록 위치를 변경할 수 있습니다. 그러나 테이블을 쿼리 할 때 오류가 발생합니다.

    아니요, 위치는 단일 디렉토리 여야합니다. 그러나 여러 디렉토리를 가리 키도록 위치를 변경할 수 있습니다. 그러나 테이블을 쿼리 할 때 오류가 발생합니다.

    예: 1. 아래와 같이 테이블의 위치를 ​​변경하십시오. ‘:’로 구분 된 두 개의 hdfs 디렉토리를 입력하고‘,’및 ';'도 시도했습니다. 성공했습니다.

    hive> alter table ext set location 'hdfs:///solytr:/ext';
    OK
    Time taken: 0.086 seconds
    
  4. ==============================

    4.SymlinkTextInputFormat / https://issues.apache.org/jira/browse/HIVE-1272를 살펴보십시오. 문제를 해결할 수 있다고 생각하십시오. 모든 위치에 별도의 텍스트 파일을 유지해야합니다!

    SymlinkTextInputFormat / https://issues.apache.org/jira/browse/HIVE-1272를 살펴보십시오. 문제를 해결할 수 있다고 생각하십시오. 모든 위치에 별도의 텍스트 파일을 유지해야합니다!

    https://issues.apache.org/jira/browse/HIVE-951도 참조하십시오. 해결되지 않았지만 해결책이 될 것입니다!

  5. from https://stackoverflow.com/questions/16897778/can-i-point-multiple-location-to-same-hive-external-table by cc-by-sa and MIT license