MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / test_basic_visitor

Function test_basic_visitor

src/sql-parser/tests/sqlparser_common.rs:127–230  ·  view source on GitHub ↗

unsupported operation: can't call foreign function `rust_psm_stack_pointer` on OS `linux`

()

Source from the content-addressed store, hash-verified

125#[mz_ore::test]
126#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `rust_psm_stack_pointer` on OS `linux`
127fn test_basic_visitor() -> Result<(), Box<dyn Error>> {
128 struct Visitor<'a> {
129 seen_idents: Vec<&'a str>,
130 }
131
132 impl<'a> Visit<'a, Raw> for Visitor<'a> {
133 fn visit_ident(&mut self, ident: &'a Ident) {
134 self.seen_idents.push(ident.as_str());
135 }
136 fn visit_item_name(&mut self, item_name: &'a <Raw as AstInfo>::ItemName) {
137 if let RawItemName::Name(name) = item_name {
138 for ident in &name.0 {
139 self.seen_idents.push(ident.as_str());
140 }
141 }
142 }
143 fn visit_data_type(&mut self, data_type: &'a <Raw as AstInfo>::DataType) {
144 if let RawDataType::Other { name, .. } = data_type {
145 self.visit_item_name(name)
146 }
147 }
148 }
149
150 let stmts = parser::parse_statements(
151 r#"
152 WITH a01 AS (SELECT 1)
153 SELECT *, a02.*, a03 AS a04
154 FROM (SELECT * FROM a05) a06 (a07)
155 JOIN a08 ON a09.a10 = a11.a12
156 WHERE a13
157 GROUP BY a14
158 HAVING a15
159 UNION ALL
160 SELECT a16 IS NULL
161 AND a17 IS NOT NULL
162 AND a18 IN (a19)
163 AND a20 IN (SELECT * FROM a21)
164 AND CAST(a22 AS int)
165 AND (a23)
166 AND NOT a24
167 AND a25(a26)
168 AND CASE a27 WHEN a28 THEN a29 ELSE a30 END
169 AND a31 BETWEEN a32 AND a33
170 AND a34 COLLATE a35 = a36
171 AND DATE_PART('YEAR', a37)
172 AND (SELECT a38)
173 AND EXISTS (SELECT a39)
174 FROM a40(a41) AS a42
175 LEFT JOIN a43 ON false
176 RIGHT JOIN a44 ON false
177 FULL JOIN a45 ON false
178 JOIN a46 (a47) USING (a48)
179 NATURAL JOIN (a49 NATURAL JOIN a50)
180 EXCEPT
181 (SELECT a51(a52) OVER (PARTITION BY a53 ORDER BY a54 ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING))
182 ORDER BY a55
183 LIMIT 1;
184 UPDATE b01 SET b02 = b03 WHERE b04;

Callers

nothing calls this directly

Calls 1

parse_statementsFunction · 0.50

Tested by

no test coverage detected