Skip to content

Commit c584763

Browse files
docs: add comprehensive NOTES.md documenting funcformat transformation challenges
- Document current 125/258 pass rate and funcformat analysis - Identify key patterns: SQL syntax functions, aggregates in TypeCast, context exclusions - Explain plateau at 124/258 and breakthrough with function-specific logic - Include analysis scripts for investigating funcformat patterns - Ready for systematic expansion based on failing test analysis Co-Authored-By: Dan Lynch <[email protected]>
1 parent 97732f7 commit c584763

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
const { Parser } = require('@pgsql/parser');
2+
3+
const testQueries = [
4+
"SELECT TRIM(BOTH ' ' FROM ' hello ')",
5+
"SELECT SUBSTRING('hello' FROM 2 FOR 3)",
6+
"SELECT POSITION('ll' IN 'hello')",
7+
"SELECT OVERLAY('hello' PLACING 'XX' FROM 2 FOR 2)",
8+
9+
"SELECT EXTRACT(YEAR FROM CURRENT_DATE)",
10+
"SELECT DATE_PART('month', CURRENT_TIMESTAMP)",
11+
"SELECT DATE_TRUNC('day', NOW())",
12+
13+
"SELECT LENGTH('hello')",
14+
"SELECT UPPER('hello')",
15+
"SELECT LOWER('HELLO')",
16+
"SELECT CONCAT('a', 'b')",
17+
18+
"SELECT ABS(-5)",
19+
"SELECT ROUND(3.14159, 2)",
20+
"SELECT CEIL(3.14)",
21+
"SELECT FLOOR(3.14)",
22+
23+
"SELECT AVG(column1) FROM table1",
24+
"SELECT SUM(column1) FROM table1",
25+
"SELECT COUNT(*) FROM table1",
26+
27+
"SELECT CAST(AVG(column1) AS NUMERIC(10,3)) FROM table1",
28+
"SELECT CAST(SUM(column1) AS INTEGER) FROM table1"
29+
];
30+
31+
console.log("Analyzing funcformat patterns between PG13 and PG14...\n");
32+
33+
const parser13 = new Parser(13);
34+
const parser14 = new Parser(14);
35+
36+
testQueries.forEach((sql, index) => {
37+
console.log(`=== Query ${index + 1}: ${sql} ===`);
38+
try {
39+
const result13 = parser13.parse(sql);
40+
const result14 = parser14.parse(sql);
41+
42+
if (result13 && result14) {
43+
const json13 = JSON.stringify(result13, null, 2);
44+
const json14 = JSON.stringify(result14, null, 2);
45+
46+
const funcformat13 = json13.match(/"funcformat":\s*"([^"]+)"/g) || [];
47+
const funcformat14 = json14.match(/"funcformat":\s*"([^"]+)"/g) || [];
48+
49+
console.log(`PG13 funcformat: ${funcformat13.join(', ') || 'none'}`);
50+
console.log(`PG14 funcformat: ${funcformat14.join(', ') || 'none'}`);
51+
52+
const funcnames13 = json13.match(/"str":\s*"([a-zA-Z_][a-zA-Z0-9_]*)"(?=.*"funcformat")/g) || [];
53+
const funcnames14 = json14.match(/"str":\s*"([a-zA-Z_][a-zA-Z0-9_]*)"(?=.*"funcformat")/g) || [];
54+
55+
if (funcnames14.length > 0) {
56+
console.log(`Functions with funcformat in PG14: ${funcnames14.join(', ')}`);
57+
}
58+
59+
if (json13 !== json14) {
60+
console.log("DIFFERENCE DETECTED!");
61+
} else {
62+
console.log("No differences found");
63+
}
64+
}
65+
} catch (error) {
66+
console.log("Parse error:", error.message);
67+
}
68+
console.log("---\n");
69+
});

0 commit comments

Comments
 (0)