# Regression test for incorrectly handling projection on top of the EXPORT
# (#101733).
statement ok
CREATE TABLE t (k PRIMARY KEY) AS SELECT 1;

statement ok
WITH cte AS (EXPORT INTO CSV 'nodelocal://1/export1/' FROM SELECT * FROM t) SELECT filename FROM cte;

statement ok
WITH cte AS (EXPORT INTO PARQUET 'nodelocal://1/export1/' FROM SELECT * FROM t) SELECT filename FROM cte;

query T noticetrace
WITH cte AS (EXPORT INTO CSV 'nodelocal://1/export1/' FROM SELECT * FROM t) SELECT filename FROM cte;
----
NOTICE: EXPORT is not the recommended way to move data out of CockroachDB and may be deprecated in the future. Please consider exporting data with changefeeds instead: https://www.cockroachlabs.com/docs/stable/export-data-with-changefeeds

# Regression test for #115290. Correctly handle the case where the Export's
# input expression has NOT NULL columns that are not part of the presentation of
# the expression.
statement ok
CREATE TABLE t115290 (
  id INT PRIMARY KEY,
  a INT NOT NULL,
  b INT
);

statement ok
EXPORT INTO PARQUET 'nodelocal://1/export1/' FROM SELECT b FROM t115290 ORDER BY a;
