computed.slt 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796
  1. # Copyright 2015 - 2019 The Cockroach Authors. All rights reserved.
  2. # Copyright Materialize, Inc. and contributors. All rights reserved.
  3. #
  4. # Use of this software is governed by the Business Source License
  5. # included in the LICENSE file at the root of this repository.
  6. #
  7. # As of the Change Date specified in that file, in accordance with
  8. # the Business Source License, use of this software will be governed
  9. # by the Apache License, Version 2.0.
  10. #
  11. # This file is derived from the logic test suite in CockroachDB. The
  12. # original file was retrieved on June 10, 2019 from:
  13. #
  14. # https://github.com/cockroachdb/cockroach/blob/d2f7fbf5dd1fc1a099bbad790a2e1f7c60a66cc3/pkg/sql/logictest/testdata/logic_test/computed
  15. #
  16. # The original source code is subject to the terms of the Apache
  17. # 2.0 license, a copy of which can be found in the LICENSE file at the
  18. # root of this repository.
  19. # not supported yet
  20. halt
  21. mode cockroach
  22. statement ok
  23. CREATE TABLE with_no_column_refs (
  24. a INT,
  25. b INT,
  26. c INT AS (3) STORED
  27. )
  28. query TT
  29. SHOW CREATE TABLE with_no_column_refs
  30. ----
  31. with_no_column_refs CREATE TABLE with_no_column_refs (
  32. a INT8 NULL,
  33. b INT8 NULL,
  34. c INT8 NULL AS (3) STORED,
  35. FAMILY "primary" (a, b, c, rowid)
  36. )
  37. statement ok
  38. CREATE TABLE extra_parens (
  39. a INT,
  40. b INT,
  41. c INT AS ((3)) STORED
  42. )
  43. query TT
  44. SHOW CREATE TABLE extra_parens
  45. ----
  46. extra_parens CREATE TABLE extra_parens (
  47. a INT8 NULL,
  48. b INT8 NULL,
  49. c INT8 NULL AS ((3)) STORED,
  50. FAMILY "primary" (a, b, c, rowid)
  51. )
  52. statement error cannot write directly to computed column "c"
  53. INSERT INTO with_no_column_refs VALUES (1, 2, 3)
  54. statement error cannot write directly to computed column "c"
  55. INSERT INTO with_no_column_refs (SELECT 1, 2, 3)
  56. statement error cannot write directly to computed column "c"
  57. INSERT INTO with_no_column_refs (a, c) (SELECT 1, 3)
  58. statement error cannot write directly to computed column "c"
  59. INSERT INTO with_no_column_refs (c) VALUES (1)
  60. statement ok
  61. INSERT INTO with_no_column_refs (a, b) VALUES (1, 2)
  62. statement ok
  63. INSERT INTO with_no_column_refs VALUES (1, 2)
  64. statement error cannot write directly to computed column "c"
  65. UPDATE with_no_column_refs SET c = 1
  66. statement error cannot write directly to computed column "c"
  67. UPDATE with_no_column_refs SET (a, b, c) = (1, 2, 3)
  68. statement error cannot write directly to computed column "c"
  69. UPDATE with_no_column_refs SET (a, b, c) = (SELECT 1, 2, 3)
  70. query I
  71. SELECT c FROM with_no_column_refs
  72. ----
  73. 3
  74. 3
  75. statement ok
  76. CREATE TABLE x (
  77. a INT DEFAULT 3,
  78. b INT DEFAULT 7,
  79. c INT AS (a) STORED,
  80. d INT AS (a + b) STORED
  81. )
  82. query TT
  83. SHOW CREATE TABLE x
  84. ----
  85. x CREATE TABLE x (
  86. a INT8 NULL DEFAULT 3:::INT8,
  87. b INT8 NULL DEFAULT 7:::INT8,
  88. c INT8 NULL AS (a) STORED,
  89. d INT8 NULL AS (a + b) STORED,
  90. FAMILY "primary" (a, b, c, d, rowid)
  91. )
  92. query TTBTTTB colnames
  93. SHOW COLUMNS FROM x
  94. ----
  95. column_name data_type is_nullable column_default generation_expression indices is_hidden
  96. a INT8 true 3:::INT8 · {} false
  97. b INT8 true 7:::INT8 · {} false
  98. c INT8 true NULL a {} false
  99. d INT8 true NULL a + b {} false
  100. rowid INT8 false unique_rowid() · {primary} true
  101. statement error cannot write directly to computed column "c"
  102. INSERT INTO x (c) VALUES (1)
  103. statement ok
  104. INSERT INTO x (a, b) VALUES (1, 2)
  105. query II
  106. SELECT c, d FROM x
  107. ----
  108. 1 3
  109. statement ok
  110. DELETE FROM x
  111. statement ok
  112. DELETE FROM x
  113. statement ok
  114. DROP TABLE x
  115. statement ok
  116. CREATE TABLE x (
  117. a INT NOT NULL,
  118. b INT,
  119. c INT AS (a) STORED,
  120. d INT AS (a + b) STORED
  121. )
  122. statement ok
  123. INSERT INTO x (a) VALUES (1)
  124. statement error null value in column "a" violates not-null constraint
  125. INSERT INTO x (b) VALUES (1)
  126. query II
  127. SELECT c, d FROM x
  128. ----
  129. 1 NULL
  130. statement ok
  131. DROP TABLE x
  132. # Check with upserts
  133. statement ok
  134. CREATE TABLE x (
  135. a INT PRIMARY KEY,
  136. b INT,
  137. c INT AS (b + 1) STORED,
  138. d INT AS (b - 1) STORED
  139. )
  140. statement ok
  141. INSERT INTO x (a, b) VALUES (1, 1) ON CONFLICT (a) DO UPDATE SET b = excluded.b + 1
  142. query II
  143. SELECT c, d FROM x
  144. ----
  145. 2 0
  146. statement ok
  147. INSERT INTO x (a, b) VALUES (1, 1) ON CONFLICT (a) DO UPDATE SET b = excluded.b + 1
  148. query IIII
  149. SELECT a, b, c, d FROM x
  150. ----
  151. 1 2 3 1
  152. statement ok
  153. INSERT INTO x (a, b) VALUES (1, 1) ON CONFLICT (a) DO UPDATE SET b = x.b + 1
  154. query III
  155. SELECT a, b, c FROM x
  156. ----
  157. 1 3 4
  158. # Update.
  159. statement ok
  160. UPDATE x SET b = 3
  161. query III
  162. SELECT a, b, c FROM x
  163. ----
  164. 1 3 4
  165. # Update/self-reference.
  166. statement ok
  167. UPDATE x SET b = c
  168. query III
  169. SELECT a, b, c FROM x
  170. ----
  171. 1 4 5
  172. # Updating with default is not allowed.
  173. statement error cannot write directly to computed column "c"
  174. UPDATE x SET (b, c) = (1, DEFAULT)
  175. # Upsert using the UPSERT shorthand.
  176. statement ok
  177. UPSERT INTO x (a, b) VALUES (1, 2)
  178. query IIII
  179. SELECT a, b, c, d FROM x
  180. ----
  181. 1 2 3 1
  182. statement ok
  183. TRUNCATE x
  184. # statement ok
  185. # INSERT INTO x VALUES (2, 3) ON CONFLICT (a) DO UPDATE SET a = 2, b = 3
  186. statement ok
  187. UPSERT INTO x VALUES (2, 3)
  188. query IIII
  189. SELECT a, b, c, d FROM x
  190. ----
  191. 2 3 4 2
  192. statement ok
  193. TRUNCATE x
  194. statement error cannot write directly to computed column "c"
  195. UPSERT INTO x VALUES (2, 3, 12)
  196. statement ok
  197. UPSERT INTO x (a, b) VALUES (2, 3)
  198. query IIII
  199. SELECT a, b, c, d FROM x
  200. ----
  201. 2 3 4 2
  202. statement ok
  203. DROP TABLE x
  204. # TODO(justin): cockroach#22434
  205. # statement ok
  206. # CREATE TABLE x (
  207. # b INT AS a STORED,
  208. # a INT
  209. # )
  210. #
  211. # statement ok
  212. # INSERT INTO x VALUES (DEFAULT, 1)
  213. #
  214. # statement ok
  215. # INSERT INTO x VALUES (DEFAULT, '2')
  216. #
  217. # query I
  218. # SELECT b FROM x ORDER BY b
  219. # ----
  220. # 1
  221. # 2
  222. #
  223. # statement ok
  224. # DROP TABLE x
  225. statement error use AS \( <expr> \) STORED
  226. CREATE TABLE y (
  227. a INT AS 3 STORED
  228. )
  229. statement error use AS \( <expr> \) STORED
  230. CREATE TABLE y (
  231. a INT AS (3)
  232. )
  233. statement error unimplemented at or near "virtual"
  234. CREATE TABLE y (
  235. a INT AS (3) VIRTUAL
  236. )
  237. statement error expected computed column expression to have type int, but .* has type text
  238. CREATE TABLE y (
  239. a INT AS ('not an integer!'::STRING) STORED
  240. )
  241. # We utilize the types from other columns.
  242. statement error expected computed column expression to have type int, but 'a' has type text
  243. CREATE TABLE y (
  244. a STRING,
  245. b INT AS (a) STORED
  246. )
  247. statement error impure functions are not allowed in computed column
  248. CREATE TABLE y (
  249. a TIMESTAMP AS (now()) STORED
  250. )
  251. statement error impure functions are not allowed in computed column
  252. CREATE TABLE y (
  253. a STRING AS (concat(now()::STRING, uuid_v4()::STRING)) STORED
  254. )
  255. statement error computed columns cannot reference other computed columns
  256. CREATE TABLE y (
  257. a INT AS (3) STORED,
  258. b INT AS (a) STORED
  259. )
  260. statement error column "a" does not exist
  261. CREATE TABLE y (
  262. b INT AS (a) STORED
  263. )
  264. statement error aggregate functions are not allowed in computed column
  265. CREATE TABLE y (
  266. b INT AS (count(1)) STORED
  267. )
  268. statement error computed columns cannot have default values
  269. CREATE TABLE y (
  270. a INT AS (3) STORED DEFAULT 4
  271. )
  272. # TODO(justin,bram): this should be allowed.
  273. statement ok
  274. CREATE TABLE x (a INT PRIMARY KEY)
  275. statement error computed columns cannot reference non-restricted FK columns
  276. CREATE TABLE y (
  277. q INT REFERENCES x (a) ON UPDATE CASCADE,
  278. r INT AS (q) STORED
  279. )
  280. statement error computed columns cannot reference non-restricted FK columns
  281. CREATE TABLE y (
  282. q INT REFERENCES x (a) ON DELETE CASCADE,
  283. r INT AS (q) STORED
  284. )
  285. statement error computed column "r" cannot be a foreign key reference
  286. CREATE TABLE y (
  287. r INT AS (1) STORED REFERENCES x (a)
  288. )
  289. statement error computed column "r" cannot be a foreign key reference
  290. CREATE TABLE y (
  291. r INT AS (1) STORED REFERENCES x
  292. )
  293. statement error computed column "r" cannot be a foreign key reference
  294. CREATE TABLE y (
  295. a INT,
  296. r INT AS (1) STORED REFERENCES x
  297. )
  298. # Regression test for cockroach#36036.
  299. statement ok
  300. CREATE TABLE tt (i INT8 AS (1) STORED)
  301. statement error variable sub-expressions are not allowed in computed column
  302. ALTER TABLE tt ADD COLUMN c STRING AS ((SELECT NULL)) STORED
  303. statement error computed columns cannot reference other computed columns
  304. ALTER TABLE tt ADD COLUMN c INT8 AS (i) STORED
  305. # Composite FK.
  306. statement ok
  307. CREATE TABLE xx (
  308. a INT,
  309. b INT,
  310. UNIQUE (a, b)
  311. )
  312. statement error computed column "y" cannot be a foreign key reference
  313. CREATE TABLE yy (
  314. x INT,
  315. y INT AS (3) STORED,
  316. FOREIGN KEY (x, y) REFERENCES xx (a, b)
  317. )
  318. statement error computed column "y" cannot be a foreign key reference
  319. CREATE TABLE yy (
  320. x INT,
  321. y INT AS (3) STORED,
  322. FOREIGN KEY (y, x) REFERENCES xx (a, b)
  323. )
  324. statement ok
  325. DROP TABLE xx
  326. statement ok
  327. CREATE TABLE y (
  328. r INT AS (1) STORED,
  329. INDEX (r)
  330. )
  331. statement error computed column "r" cannot be a foreign key reference
  332. ALTER TABLE y ADD FOREIGN KEY (r) REFERENCES x (a)
  333. statement ok
  334. DROP TABLE y
  335. statement error variable sub-expressions are not allowed in computed column
  336. CREATE TABLE y (
  337. r INT AS ((SELECT 1)) STORED
  338. )
  339. statement error no data source matches prefix: x
  340. CREATE TABLE y (
  341. r INT AS (x.a) STORED
  342. )
  343. statement error no data source matches prefix: x
  344. CREATE TABLE y (
  345. q INT,
  346. r INT AS (x.q) STORED
  347. )
  348. statement ok
  349. CREATE TABLE y (
  350. q INT,
  351. r INT AS (y.q) STORED
  352. )
  353. statement ok
  354. DROP TABLE y
  355. # It's ok if they exist and we don't reference them.
  356. statement ok
  357. CREATE TABLE y (
  358. q INT REFERENCES x (a) ON UPDATE CASCADE,
  359. r INT AS (3) STORED
  360. )
  361. statement ok
  362. DROP TABLE y
  363. statement ok
  364. DROP TABLE x
  365. # Indexes on computed columns
  366. statement ok
  367. CREATE TABLE x (
  368. k INT PRIMARY KEY,
  369. a JSON,
  370. b TEXT AS (a->>'q') STORED,
  371. INDEX (b)
  372. )
  373. statement error cannot write directly to computed column
  374. INSERT INTO x (k, a, b) VALUES (1, '{"q":"xyz"}', 'not allowed!'), (2, '{"q":"abc"}', 'also not allowed')
  375. statement error cannot write directly to computed column
  376. UPDATE x SET (k, a, b) = (1, '{"q":"xyz"}', 'not allowed!')
  377. statement ok
  378. INSERT INTO x (k, a) VALUES (1, '{"q":"xyz"}'), (2, '{"q":"abc"}')
  379. query IT
  380. SELECT k, b FROM x ORDER BY b
  381. ----
  382. 2 abc
  383. 1 xyz
  384. statement ok
  385. DROP TABLE x
  386. statement ok
  387. CREATE TABLE x (
  388. k INT AS ((data->>'id')::INT) STORED PRIMARY KEY,
  389. data JSON
  390. )
  391. statement ok
  392. INSERT INTO x (data) VALUES
  393. ('{"id": 1, "name": "lucky"}'),
  394. ('{"id": 2, "name": "rascal"}'),
  395. ('{"id": 3, "name": "captain"}'),
  396. ('{"id": 4, "name": "lola"}')
  397. # ON CONFLICT that modifies a PK.
  398. statement ok
  399. INSERT INTO x (data) VALUES ('{"id": 1, "name": "ernie"}')
  400. ON CONFLICT (k) DO UPDATE SET data = '{"id": 5, "name": "ernie"}'
  401. # ON CONFLICT that modifies a PK which then also conflicts.
  402. statement error duplicate key value
  403. INSERT INTO x (data) VALUES ('{"id": 5, "name": "oliver"}')
  404. ON CONFLICT (k) DO UPDATE SET data = '{"id": 2, "name": "rascal"}'
  405. # Updating a non-PK column.
  406. statement ok
  407. UPDATE x SET data = data || '{"name": "carl"}' WHERE k = 2
  408. query T
  409. SELECT data->>'name' FROM x WHERE k = 2
  410. ----
  411. carl
  412. query T
  413. SELECT data->>'name' FROM x WHERE k = 5
  414. ----
  415. ernie
  416. # Referencing a computed column.
  417. statement ok
  418. create table y (
  419. a INT REFERENCES x (k)
  420. )
  421. statement ok
  422. INSERT INTO y VALUES (5)
  423. statement error foreign key violation
  424. INSERT INTO y VALUES (100)
  425. statement ok
  426. DROP TABLE x CASCADE
  427. statement ok
  428. CREATE TABLE x (
  429. a INT,
  430. b INT,
  431. c INT,
  432. d INT[] AS (ARRAY[a, b, c]) STORED
  433. )
  434. statement ok
  435. INSERT INTO x (a, b, c) VALUES (1, 2, 3)
  436. query T
  437. SELECT d FROM x
  438. ----
  439. {1,2,3}
  440. statement ok
  441. TRUNCATE x
  442. # Make sure we get the permutation on the inserts correct.
  443. statement ok
  444. INSERT INTO x (b, a, c) VALUES (1, 2, 3)
  445. query T
  446. SELECT d FROM x
  447. ----
  448. {2,1,3}
  449. # Make sure we get the permutation on the updates correct.
  450. statement ok
  451. UPDATE x SET (c, a, b) = (1, 2, 3)
  452. query T
  453. SELECT d FROM x
  454. ----
  455. {2,3,1}
  456. statement ok
  457. UPDATE x SET (a, c) = (1, 2)
  458. query T
  459. SELECT d FROM x
  460. ----
  461. {1,3,2}
  462. statement ok
  463. UPDATE x SET c = 2, a = 3, b = 1
  464. query T
  465. SELECT d FROM x
  466. ----
  467. {3,1,2}
  468. # Make sure we get the permutation on upserts correct.
  469. statement ok
  470. INSERT INTO x (rowid) VALUES ((SELECT rowid FROM x)) ON CONFLICT(rowid) DO UPDATE SET (a, b, c) = (1, 2, 3)
  471. query T
  472. SELECT d FROM x
  473. ----
  474. {1,2,3}
  475. statement ok
  476. INSERT INTO x (rowid) VALUES ((SELECT rowid FROM x)) ON CONFLICT(rowid) DO UPDATE SET (c, a, b) = (1, 2, 3)
  477. query T
  478. SELECT d FROM x
  479. ----
  480. {2,3,1}
  481. statement ok
  482. INSERT INTO x (rowid) VALUES ((SELECT rowid FROM x)) ON CONFLICT(rowid) DO UPDATE SET (c, a) = (1, 2)
  483. query T
  484. SELECT d FROM x
  485. ----
  486. {2,3,1}
  487. statement ok
  488. DROP TABLE x
  489. statement ok
  490. CREATE TABLE x (
  491. a INT,
  492. b INT as (x.a) STORED
  493. )
  494. query TT
  495. SHOW CREATE TABLE x
  496. ----
  497. x CREATE TABLE x (
  498. a INT8 NULL,
  499. b INT8 NULL AS (a) STORED,
  500. FAMILY "primary" (a, b, rowid)
  501. )
  502. statement ok
  503. DROP TABLE x
  504. # Check that computed columns are resilient to column renames.
  505. statement ok
  506. CREATE TABLE x (
  507. a INT,
  508. b INT AS (a) STORED
  509. )
  510. statement ok
  511. ALTER TABLE x RENAME COLUMN a TO c
  512. query TT
  513. SHOW CREATE TABLE x
  514. ----
  515. x CREATE TABLE x (
  516. c INT8 NULL,
  517. b INT8 NULL AS (c) STORED,
  518. FAMILY "primary" (c, b, rowid)
  519. )
  520. statement ok
  521. DROP TABLE x
  522. statement ok
  523. CREATE TABLE x (
  524. a INT,
  525. b INT AS (a * 2) STORED
  526. )
  527. query T colnames
  528. SELECT generation_expression FROM information_schema.columns
  529. WHERE table_name = 'x' and column_name = 'b'
  530. ----
  531. generation_expression
  532. a * 2
  533. query I
  534. SELECT count(*) FROM information_schema.columns
  535. WHERE table_name = 'x' and generation_expression = ''
  536. ----
  537. 2
  538. statement ok
  539. INSERT INTO x VALUES (3)
  540. # Verify computed columns work.
  541. statement ok
  542. ALTER TABLE x ADD COLUMN c INT NOT NULL AS (a + 4) STORED
  543. query TT
  544. SHOW CREATE TABLE x
  545. ----
  546. x CREATE TABLE x (
  547. a INT8 NULL,
  548. b INT8 NULL AS (a * 2) STORED,
  549. c INT8 NOT NULL AS (a + 4) STORED,
  550. FAMILY "primary" (a, b, rowid, c)
  551. )
  552. statement ok
  553. INSERT INTO x VALUES (6)
  554. query III
  555. SELECT * FROM x ORDER BY a
  556. ----
  557. 3 6 7
  558. 6 12 10
  559. # Verify a bad statement fails.
  560. statement error unsupported binary operator: <int> \+ <string> \(desired <int>\)
  561. ALTER TABLE x ADD COLUMN d INT AS (a + 'a') STORED
  562. statement error could not parse "a" as type int
  563. ALTER TABLE x ADD COLUMN d INT AS ('a') STORED
  564. statement error unsupported binary operator
  565. ALTER TABLE x ADD COLUMN d INT AS (a / 0) STORED
  566. # Verify an error during computation fails.
  567. statement error division by zero
  568. ALTER TABLE x ADD COLUMN d INT AS (a // 0) STORED
  569. statement ok
  570. DROP TABLE x
  571. # Regression test for materialize#23109
  572. statement ok
  573. CREATE TABLE x (
  574. a INT DEFAULT 1,
  575. b INT AS (2) STORED
  576. )
  577. statement ok
  578. INSERT INTO x (a) SELECT 1
  579. statement ok
  580. DROP TABLE x
  581. statement ok
  582. CREATE TABLE x (
  583. b INT AS (2) STORED,
  584. a INT DEFAULT 1
  585. )
  586. statement ok
  587. INSERT INTO x (a) SELECT 1
  588. statement ok
  589. DROP TABLE x
  590. # Verify errors emitted from computed columns contain the column name
  591. statement ok
  592. CREATE TABLE error_check (k INT PRIMARY KEY, s STRING, i INT AS (s::INT) STORED)
  593. statement ok
  594. INSERT INTO error_check VALUES(1, '1')
  595. statement error could not parse "foo" as type int: strconv.ParseInt
  596. INSERT INTO error_check VALUES(2, 'foo')
  597. statement error could not parse "foo" as type int: strconv.ParseInt: parsing "foo": invalid syntax
  598. UPDATE error_check SET s = 'foo' WHERE k = 1
  599. # Upsert -> update
  600. # NOTE: The CBO cannot show the name of the computed column in the error message
  601. # because the computation is part of an overall SQL statement.
  602. statement error could not parse "foo" as type int: strconv.ParseInt: parsing "foo": invalid syntax
  603. UPSERT INTO error_check VALUES (1, 'foo')
  604. # Upsert -> insert
  605. statement error could not parse "foo" as type int: strconv.ParseInt: parsing "foo": invalid syntax
  606. UPSERT INTO error_check VALUES (3, 'foo')
  607. statement ok
  608. CREATE TABLE x (
  609. a INT PRIMARY KEY,
  610. b INT AS (a+1) STORED
  611. )
  612. query error value type decimal doesn't match type int of column "a"
  613. INSERT INTO x VALUES(1.4)
  614. # Regression test for cockroach#34901: verify that builtins can be used in computed
  615. # column expressions without a "memory budget exceeded" error while backfilling
  616. statement ok
  617. CREATE TABLE t34901 (x STRING)
  618. statement ok
  619. INSERT INTO t34901 VALUES ('a')
  620. statement ok
  621. ALTER TABLE t34901 ADD COLUMN y STRING AS (concat(x, 'b')) STORED
  622. query TT
  623. SELECT * FROM t34901
  624. ----
  625. a ab