ORC SerDe - Amazon Athena

ORC SerDe

ORC SerDe를 사용하여 ORC 데이터에서 Athena 테이블을 생성합니다.

직렬화 라이브러리 이름

ORC SerDe의 직렬화 라이브러리는 org.apache.hadoop.hive.ql.io.orc.OrcSerde이지만 CREATE TABLE 문에서는 STORED AS ORC 절을 사용하여 이 항목을 지정합니다. 소스 코드 정보는 GitHub.com의 OrcSerde.java를 참조하세요.

참고

s3://athena-examples-myregion/path/to/data/myregion을, Athena를 실행하는 리전 식별자로 바꿉니다(예: s3://athena-examples-us-west-1/path/to/data/).

다음 예에서는 ORC에 비행 지연 데이터의 테이블을 생성합니다. 테이블에 파티션이 포함됩니다.

DROP TABLE flight_delays_orc; CREATE EXTERNAL TABLE flight_delays_orc ( yr INT, quarter INT, month INT, dayofmonth INT, dayofweek INT, flightdate STRING, uniquecarrier STRING, airlineid INT, carrier STRING, tailnum STRING, flightnum STRING, originairportid INT, originairportseqid INT, origincitymarketid INT, origin STRING, origincityname STRING, originstate STRING, originstatefips STRING, originstatename STRING, originwac INT, destairportid INT, destairportseqid INT, destcitymarketid INT, dest STRING, destcityname STRING, deststate STRING, deststatefips STRING, deststatename STRING, destwac INT, crsdeptime STRING, deptime STRING, depdelay INT, depdelayminutes INT, depdel15 INT, departuredelaygroups INT, deptimeblk STRING, taxiout INT, wheelsoff STRING, wheelson STRING, taxiin INT, crsarrtime INT, arrtime STRING, arrdelay INT, arrdelayminutes INT, arrdel15 INT, arrivaldelaygroups INT, arrtimeblk STRING, cancelled INT, cancellationcode STRING, diverted INT, crselapsedtime INT, actualelapsedtime INT, airtime INT, flights INT, distance INT, distancegroup INT, carrierdelay INT, weatherdelay INT, nasdelay INT, securitydelay INT, lateaircraftdelay INT, firstdeptime STRING, totaladdgtime INT, longestaddgtime INT, divairportlandings INT, divreacheddest INT, divactualelapsedtime INT, divarrdelay INT, divdistance INT, div1airport STRING, div1airportid INT, div1airportseqid INT, div1wheelson STRING, div1totalgtime INT, div1longestgtime INT, div1wheelsoff STRING, div1tailnum STRING, div2airport STRING, div2airportid INT, div2airportseqid INT, div2wheelson STRING, div2totalgtime INT, div2longestgtime INT, div2wheelsoff STRING, div2tailnum STRING, div3airport STRING, div3airportid INT, div3airportseqid INT, div3wheelson STRING, div3totalgtime INT, div3longestgtime INT, div3wheelsoff STRING, div3tailnum STRING, div4airport STRING, div4airportid INT, div4airportseqid INT, div4wheelson STRING, div4totalgtime INT, div4longestgtime INT, div4wheelsoff STRING, div4tailnum STRING, div5airport STRING, div5airportid INT, div5airportseqid INT, div5wheelson STRING, div5totalgtime INT, div5longestgtime INT, div5wheelsoff STRING, div5tailnum STRING ) PARTITIONED BY (year String) STORED AS ORC LOCATION 's3://athena-examples-myregion/flight/orc/' tblproperties ("orc.compress"="ZLIB");

테이블에서 MSCK REPAIR TABLE 문을 실행해 파티션 메타데이터를 새로 고칩니다:

MSCK REPAIR TABLE flight_delays_orc;

이 쿼리를 사용해 1시간 이상 지연된 상위 10개 경로를 얻습니다.

SELECT origin, dest, count(*) as delays FROM flight_delays_orc WHERE depdelayminutes > 60 GROUP BY origin, dest ORDER BY 3 DESC LIMIT 10;