๐Ÿฅ

[airflow] mariadb๋ฅผ external database๋กœ ์‚ฌ์šฉ ์‹œ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๊ด€๋ จ ์˜ค๋ฅ˜ (column doesn't exist) ๋ณธ๋ฌธ

๋ฐ์ดํ„ฐ/database

[airflow] mariadb๋ฅผ external database๋กœ ์‚ฌ์šฉ ์‹œ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๊ด€๋ จ ์˜ค๋ฅ˜ (column doesn't exist)

•8• 2023. 8. 14. 15:05

์ •ํ™•ํžˆ ์–ด๋–ค ์˜ค๋ฅ˜ ๋ฌธ๊ตฌ์˜€๋Š”์ง€๋Š” db ์˜ต์…˜๊ฐ’์„ ์ด๋ฏธ ์ˆ˜์ •ํ•ด๋ฒ„๋ ค์„œ ์žฌํ˜„์€ ์–ด๋ ต์ง€๋งŒ

airflow ์Šค์ผ€์ฅด๋Ÿฌ์—์„œ db๋ฅผ ์ฟผ๋ฆฌํ•  ๋•Œ syntax error๊ฐ€ ๋‚œ๋‹ค๋Š” ์˜ค๋ฅ˜์˜€๋‹ค. (๋Œ€์ถฉ ์•„๋ž˜ ์˜ค๋ฅ˜ ๋Š๋‚Œ..)

db init์„ ํ•˜๋Š”๋ฐ select ์ ˆ์— ์žˆ๋Š” ์ปฌ๋Ÿผ๋“ค์ด group by ์ ˆ์— ์—†๋Š” ์˜ค๋ฅ˜
"table.column" doesn't exist.

airflow์—์„œ๋Š” ๊ณต์‹์ ์œผ๋กœ mariadb๋ฅผ ์ง€์›ํ•˜์ง€ ์•Š๋Š”๋‹ค.

(์ฐธ๊ณ : https://airflow.apache.org/docs/apache-airflow/stable/howto/set-up-database.html)

Despite big similarities between MariaDB and MySQL, we DO NOT support MariaDB as a backend for Airflow.

mysql๊ณผ mariadb์˜ group by ์‚ฌ์šฉ๋ฒ•์„ ํ™•์ธํ•ด๋ณด๋‹ˆ ์‹ค์ œ๋กœ ์•„๋ž˜์™€ ๊ฐ™์€ ์ฐจ์ด์ ์ด ์žˆ์—ˆ๋‹ค.

 

[mysql]

select A, B, C

from some_table

group by A

-> ๊ฐ€๋Šฅ

 

[mariadb]

select A, B, C

from some_table

group by A

-> ๋ถˆ๊ฐ€๋Šฅ. select ์ ˆ์— ์žˆ๋Š” ๋ชจ๋“  ์ปฌ๋Ÿผ์ด group by ์ ˆ์— ์žˆ์–ด์•ผ ํ•จ

 

์–ด์จŒ๋“  mariadb์™€ ์—ฐ๊ฒฐํ•ด์•ผํ•˜๋Š” ์ƒํ™ฉ์ด์—ˆ๊ณ  ๋‚ด๊ฐ€ ์‚ฌ์šฉํ•œ ๋ฐฉ๋ฒ•์€ ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

(์ฐธ๊ณ : https://mariadb.com/kb/en/sql-mode/#only_full_group_by)

SELECT @@SQL_MODE, @@GLOBAL.SQL_MODE;

์œ„ ๋ณ€์ˆ˜๋“ค์„ ํ™•์ธ ์‹œ์— ์•„๋ž˜์™€ ๊ฐ™์€ ์˜ต์…˜์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

์ด์ค‘์— ONLY_FULL_GROUP_BY ์‚ญ์ œํ•œ ๋ฆฌ์ŠคํŠธ๋ฅผ ์ ์šฉ์‹œ์ผœ ์ฃผ๋ฉด ๋œ๋‹ค.

PIPES_AS_CONCAT,STRICT_TRANS_TABLES,ONLY_FULL_GROUP_BY,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

 

`@@SQL_MODE`๋Š” ํ˜„์žฌ ์„ธ์…˜์—๋งŒ ์ ์šฉ๋˜๋Š” ์˜ต์…˜๋“ค์ด์–ด์„œ ์„ธ์…˜์„ ๋‚˜๊ฐ€๋ฉด ์ดˆ๊ธฐํ™”๋œ๋‹ค.
`GLOBAL.SQL_MODE`๋กœ ์ ์šฉ์‹œ์ผœ์ฃผ์–ด์•ผ ํ•œ๋‹ค.
ํ˜น์‹œ ๋ชจ๋ฅด๋‹ˆ `SQL_MODE` ์—์„œ ๋จผ์ € ์ ์šฉ ํ›„ ๋ฌธ์ œ๊ฐ€ ๋˜์—ˆ๋˜ ์ฟผ๋ฆฌ๊ฐ€ ์ •์ƒ ๋™์ž‘ํ•˜๋Š”์ง€ ํ™•์ธํ•ด๋ณด๊ณ  `GLOBAL.SQL_MODE` ๋ฅผ ๋ณ€๊ฒฝํ•˜๋Š” ๊ฒƒ์„ ์ถ”์ฒœํ•œ๋‹ค.