본문 바로가기

전체보기

(33)
[spark] dataframe get row value 데이터 전처리 원하는 특정 열 (쿼리로 치면 where절) getRowDf = df.filter("col_name = 'value'") 원하는 특정 칼럼들 getColDf = df.select("col1","col2") for row in df.rdd.collect(): print(rolw)
[hive] partition add / delete ALTER TABLE tmp.table ADD IF NOT EXISTS PARTITION (base_dt='2020-06-01') ALTER TABLE tmp.tableDROP IF EXISTS PARTITION(year = 2012, month = 12, day = 18);
[hive] table, column add comment / add column / change column order / column rename table comment add ALTER TABLE table_name SET TBLPROPERTIES ('comment' = new_comment); column comment add ALTER TABLE table_name CHANGE col1 col1 colType COMMENT 'new_comment'; 파티션 컬럼은 테이블생성시에만 코멘트를 추가할 수 있다. Comment can be added to a partition column at the time of creation of the table. HUE > Table Browser > edit 가능 change column order ALTER TABLE tmp.table_name CHANGE col_name col_name col_typ..
[hive] partition column rename hive에서 실행할것. impala에서 하면 실행안됨 ALTER TABLE tmp.table PARTITION (base_dt='20200601') RENAME TO PARTITION (base_dt='2020-06-01') hadoop distcp /old_dir/base_dt=20200601/* /new_dir/base_dt=2020-06-01/filename 파티션 컬럼 경로 변경 ALTER TABLE tmp.table PARTITION (base_dt='2020-06-01') SET LOCATION '/newdir/base_dt=2020-06-01'
[hive] table rename , change location 테이블명 변경 alter table tmp.oldname rename to tmp.newname 경로 변경 터미널에서 파일 복사 hadoop distcp hdfs://old_dir/* hdfs://new_dir 쿼리 alter table tmp.newname set location 'hdfs://new_dir'
[pandas] dataframe get row value / 데이터 전처리 pandas dataframe for idx, member in df.iterrows(): print(idx, member) for i, member in df.iterrows(): base_dt = datetime.datetime.strptime(df.loc[i]['base_dt'],"%Y%m%d").strftime("%Y-%m-%d") count = int(df.loc[i]['COUNT(*)'].toString())
[kudu] column add/change 칼럼명 변경 alter table table_name change old_col new_col new_type 칼럼 추가 alter table table_name add columns (col1 type1, col2 type2)
[command] find filename/directoryname 파일명 찾기 find . -name "filename" 디렉토리 찾기 find . -name "dirname" -type d
[kudu] create table CREATE TABLE my_first_table ( id BIGINT, name STRING, PRIMARY KEY(id) ) PARTITION BY HASH PARTITIONS 6 STORED AS KUDU TBLPROPERTIES ('kudu.master_addresses' = 'host_name')
[반복문] skip 시 pass/continue pass : 실행할 코드가 없는 경우 continue : 다음 순번 loop 로 넘어감 for i in list: if "data" in i: pass print(i) -> i에 "data"가 포함되어도 print(i) 출력됨 for i in list: if "data" in i: continue print(i) -> 에 "data"가 포함되면 다음 loop가 돌게됨