initial BigQuery :create-table-as :or-replace
This commit is contained in:
parent
440b86633a
commit
7d56daacca
3 changed files with 25 additions and 3 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
* 2.4.next in progress
|
* 2.4.next in progress
|
||||||
|
* Support BigQuery `CREATE OR REPLACE` (work-in-progress).
|
||||||
|
* Address [#510](https://github.com/seancorfield/honeysql/issues/510) by adding some NRQL support (work-in-progress).
|
||||||
* Fix [#509](https://github.com/seancorfield/honeysql/issues/509) by checking for `ident?` before checking keyword/symbol.
|
* Fix [#509](https://github.com/seancorfield/honeysql/issues/509) by checking for `ident?` before checking keyword/symbol.
|
||||||
|
|
||||||
* 2.4.1078 -- 2023-10-07
|
* 2.4.1078 -- 2023-10-07
|
||||||
|
|
|
||||||
|
|
@ -1156,9 +1156,13 @@
|
||||||
opts (filter some? (drop-while tab? params))
|
opts (filter some? (drop-while tab? params))
|
||||||
ine (last coll)
|
ine (last coll)
|
||||||
[prequel table ine]
|
[prequel table ine]
|
||||||
(if (= :if-not-exists (sym->kw ine))
|
(let [ine-kw (sym->kw ine)]
|
||||||
[(butlast (butlast coll)) (last (butlast coll)) ine]
|
(cond (= :if-not-exists ine-kw)
|
||||||
[(butlast coll) (last coll) nil])]
|
[(butlast (butlast coll)) (last (butlast coll)) ine]
|
||||||
|
(= :or-replace ine-kw)
|
||||||
|
[(cons ine (butlast (butlast coll))) (last (butlast coll)) nil]
|
||||||
|
:else
|
||||||
|
[(butlast coll) (last coll) nil]))]
|
||||||
(into [(str/join " " (map sql-kw prequel))
|
(into [(str/join " " (map sql-kw prequel))
|
||||||
(when table (format-entity table))
|
(when table (format-entity table))
|
||||||
(when ine (sql-kw ine))]
|
(when ine (sql-kw ine))]
|
||||||
|
|
|
||||||
|
|
@ -553,6 +553,12 @@
|
||||||
(where [:= :metroflag "y"])
|
(where [:= :metroflag "y"])
|
||||||
(with-data false)))
|
(with-data false)))
|
||||||
["CREATE TABLE IF NOT EXISTS metro AS SELECT * FROM cities WHERE metroflag = ? WITH NO DATA" "y"]))
|
["CREATE TABLE IF NOT EXISTS metro AS SELECT * FROM cities WHERE metroflag = ? WITH NO DATA" "y"]))
|
||||||
|
(is (= (sql/format (-> (create-table-as :metro :or-replace)
|
||||||
|
(select :*)
|
||||||
|
(from :cities)
|
||||||
|
(where [:= :metroflag "y"])
|
||||||
|
(with-data false)))
|
||||||
|
["CREATE OR REPLACE TABLE metro AS SELECT * FROM cities WHERE metroflag = ? WITH NO DATA" "y"]))
|
||||||
(is (= (sql/format (-> (create-materialized-view :metro :if-not-exists)
|
(is (= (sql/format (-> (create-materialized-view :metro :if-not-exists)
|
||||||
(select :*)
|
(select :*)
|
||||||
(from :cities)
|
(from :cities)
|
||||||
|
|
@ -569,6 +575,16 @@
|
||||||
[(str "CREATE TABLE IF NOT EXISTS metro"
|
[(str "CREATE TABLE IF NOT EXISTS metro"
|
||||||
" (foo, bar, baz) TABLESPACE quux"
|
" (foo, bar, baz) TABLESPACE quux"
|
||||||
" AS SELECT * FROM cities WHERE metroflag = ? WITH NO DATA") "y"]))
|
" AS SELECT * FROM cities WHERE metroflag = ? WITH NO DATA") "y"]))
|
||||||
|
(is (= (sql/format (-> (create-table-as :metro :or-replace
|
||||||
|
(columns :foo :bar :baz)
|
||||||
|
[:tablespace [:entity :quux]])
|
||||||
|
(select :*)
|
||||||
|
(from :cities)
|
||||||
|
(where [:= :metroflag "y"])
|
||||||
|
(with-data false)))
|
||||||
|
[(str "CREATE OR REPLACE TABLE metro"
|
||||||
|
" (foo, bar, baz) TABLESPACE quux"
|
||||||
|
" AS SELECT * FROM cities WHERE metroflag = ? WITH NO DATA") "y"]))
|
||||||
(is (= (sql/format (-> (create-materialized-view :metro :if-not-exists
|
(is (= (sql/format (-> (create-materialized-view :metro :if-not-exists
|
||||||
(columns :foo :bar :baz)
|
(columns :foo :bar :baz)
|
||||||
[:tablespace [:entity :quux]])
|
[:tablespace [:entity :quux]])
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue