임팔라에서 동시에 여러 쿼리를 실행할 수 있습니까? 그렇다면 임팔라는 어떻게 처리합니까?cloudera impala에서 다중 쿼리 실행
2
A
답변
1
임팔라는 메모리 캡을 맞추지 않는 한 동시에 여러 쿼리를 실행할 수 있습니다.
1
당신은 파일이 여러 쿼리를 세미콜론으로 구분 된 각 전체 쿼리를 가지고 impala-shell -f <<file_name>>
, 같은 명령을 실행할 수 있습니다 (;) 당신은 파이썬 괴짜 경우
1
, 당신도 여러 개 만들 수 impyla 패키지를 시도 할 수 있습니다 연결하고 모든 쿼리를 한 번에 실행하십시오.
pip install impyla
1
나는 확실히 당신의 자신에 대한 몇 가지 테스트를 할 것입니다,하지만 난 여러 쿼리를 실행 얻을 수 없습니다 : 을 나는 임팔라 연결을 사용하고 .SQL 파일에서 쿼리를 읽고 있었다. 이것은 단일 명령에 대해 작동합니다.
from impala.dbapi import connect
# actual server and port changed for this post for security
conn=connect(host='impala server', port=11111,auth_mechanism="GSSAPI")
cursor = conn.cursor()
cursor.execute((open("sandbox/z_temp.sql").read()))
이것은 내가받은 오류입니다.
HiveServer2Error: AnalysisException: Syntax error in line 2:
이것은 SQL이 .sql 파일에서와 같이 보입니다.
Select * FROM database1.table1;
Select * FROM database1.table2;
나는 지정된 폴더에있는 모든 .SQL 파일을 반복하는 별도의 .SQL 파일의 SQL 명령으로 여러 명령을 실행 할 수 있었다.
#Create list of file names for recon .sql files this will be sorted
#Numbers at begining of filename are important to sort so that files will be executed in correct order
file_names = glob.glob('folder/.sql')
asc_names = sorted(file_names, reverse = False)
filename = ""
for file_name in asc_names:
str_filename = str(file_name)
print(filename)
query = (open(str_filename).read())
cursor = conn.cursor()
# creates an error log dataframe to print, or write to file at end of job.
try:
# Each SQL command must be executed seperately
cursor.execute(query)
df_id= pd.DataFrame([{'test_name': str_filename[-40:], 'test_status': 'PASS'}])
df_log = df_log.append(df_id, ignore_index=True)
except:
df_id= pd.DataFrame([{'test_name': str_filename[-40:], 'test_status': 'FAIL'}])
df_log = df_log.append(df_id, ignore_index=True)
continue
로 구분 한 .SQL 파일에있는 모든 SQL 문을 가지고하는 것이 작업을 수행하는 또 다른 방법; 그런 다음 .sql 파일을 통해 명령문을 나누어 루프합니다. 한 번에 하나씩 달린다.
from impala.dbapi import connect
from impala.util import as_pandas
conn=connect(host='impalaserver', port=11111, auth_mechanism='GSSAPI')
cursor = conn.cursor()
# split SQL statements from one file seperated by ';', Note: last command will not have semicolon at end.
sql_file = open("sandbox/temp.sql").read()
sql = sql_file.split(';')
for cmd in sql:
# This gets rid of the non printing characters you may have
cmd = cmd.replace('/r','')
cmd = cmd.replace('/n','')
# This runs your SQL commands one at a time.
cursor.execute(cmd)
print(cmd)
관련 문제
- 1. 분리 기능이 Cloudera Impala에서 작동하지 않습니다.
- 2. QtSql 다중 쿼리 실행
- 3. 실행 시간 Cloudera VM
- 4. Cloudera Impala : HDFS 블록의 데이터를 어떻게 읽습니까?
- 5. Java가있는 스레드에서 다중 쿼리 실행
- 6. cloudera 관리자없이 cloudera impala 설치
- 7. mysqli_multi_query와 트랜잭션을 이용한 다중 쿼리 실행
- 8. 다중 접합 테이블을 사용하여 쿼리 실행
- 9. MySQL에서 다중 쿼리 실행 (SphinxQL 용)
- 10. Cloudera VM 문제를 사용하여 Oozie 실행
- 11. Cloudera : Cloudera 관리자에게 Accumulo 1.7.2 소포 추가
- 12. 다중 쿼리
- 13. Cloudera 임팔라는 mongodb를 지원합니까?
- 14. VM cloudera - 사용자 cloudera 및 사용 권한?
- 15. Cloudera cdh 클러스터 도커 배포
- 16. 다중 배열에 다중 SQL 쿼리
- 17. 실행 전 쿼리 실행
- 18. JPA 다중 조인 쿼리
- 19. cloudera manager 무료 버전을 사용하는 hadoop 다중 노드 구성
- 20. 자바 실행 예약 다중 실행
- 21. 다중 실행 취소/다시 실행
- 22. cloudera 클러스터 노드 역할
- 23. 다중 쿼리 서브 쿼리 가입
- 24. 쿼리 실행
- 25. 쿼리 - 실행
- 26. Codeigniter 다중 삽입 쿼리
- 27. C# Mysql 다중 쿼리
- 28. 데이터베이스 컨텍스트에서 탄성 스케일 다중 분할 쿼리 실행
- 29. PHP에서 다중 MySQL 쿼리 실행 | 왜 이것이 작동하지 않습니까?
- 30. 단일 실행 단일 매개 변수의 다중 값에 대한 쿼리 선택