목록전체 글 (137)
now is better than never
SELECT date_format(start_date, '%m') month , car_id , count(*) RECORDS FROM CAR_RENTAL_COMPANY_RENTAL_HISTORY WHERE car_id in (select car_id from CAR_RENTAL_COMPANY_RENTAL_HISTORY where START_DATE between '2022-08-01' and '2022-10-31' group by car_id having count(*)>=5) AND START_DATE between '2022-08-01' and '2022-10-31' GROUP BY month, car_id HAVING records > 0 ORDER BY month asc, car_id desc ..
https://school.programmers.co.kr/learn/courses/30/lessons/151141 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr -- 코드를 입력하세요 SELECT history.HISTORY_ID, ROUND(car.DAILY_FEE * (100 - IFNULL(discount.DISCOUNT_RATE, 0))/100 * history.days) FEE FROM (SELECT * FROM CAR_RENTAL_COMPANY_CAR WHERE CAR_TYPE = '트럭') car JOIN (SELECT CAR_ID, HIS..

BaseBranchOperator BaseBranchOpertator 상속해서 class 만듦 BaseBranchOpertator 상속할 때 choose_branch 함수를 구현해야 함 parameter : context python operator의 kwargs랑 비슷 Branch Python Operator와 task.branch decorator 를 더 많이 사용함 세 방법 다 결과값은 같음 airflow.operators.branch A base class for creating operators with branching functionality, like to BranchPythonOperator. Users should create a subclass from this operator and..
Task.branch branch python operator 를 이용해서 객체를 얻었던 것을 → 함수를 실행시켜 객체를 얻음 task 정의할 때 함수를 실행시킴 decorator 밑에 rapping하고 싶은 함수를 작성 from airflow import DAG import pendulum from airflow.operators.python import PythonOperator from airflow.decorators import task with DAG( dag_id="dags_python_with_branch_decorator", schedule=None, start_date=pendulum.datetime(2023, 9, 1, tz="Asia/Seoul"), catchup=False ) as..

Task 분기 처리 선행 Task 의 수행 결과에 따라 선택적으로 다음 Task 를 수행할 경우 Branch Python Operator task.branch Decorator Base Branch Operator 상속하여 직접 개발 Branch Python Operator python_branch_task → task a, task b, task c 중 하나 실행 python callable : select_random 함수 실행 실행할 task 의 id 값으로 return 후행 task 가 1개라면 string 후행 task 가 여러 개라면 list from airflow import DAG import pendulum from airflow.operators.python import PythonOp..
Variable XCom: 특정 DAG / schedule 에서 수행되는 TASK 간에만 공유 (같은 DAG 이라도 어제와 오늘 TASK 간 데이터는 공유 X) Variable 모든 DAG 이 공유 airflow 사이트에서 등록 가능 Admin > variables Variable의 key, value 값은 메타 DB의 variable 테이블에 저장됨 전역변수 사용 Variable 라이브러리 + 파이썬 문법 *from airflow.models import Variable *→ 주기적인 DAG 파싱 시 Variable.get 개수만큼 DB(메타DB variable 테이블) 연결 → 불필요한 부하 발생 Jinja template + 오퍼레이터 내부 (권고) {{var.value.}} 협업 환경에서 표준화된..