Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] fix path expression steps for nested expressions #159

Closed
am357 opened this issue Jul 26, 2022 · 0 comments
Closed

[bug] fix path expression steps for nested expressions #159

am357 opened this issue Jul 26, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@am357
Copy link
Contributor

am357 commented Jul 26, 2022

This issue has been spotted by @alancai98 when reviewing #158:
"The parsed AST output by parse_partiql doesn't include nodes along the path other than the start and final nodes (for this example test, only has a, and f[1+2])."

Example

[partiql-parser/src/parse/mod.rs:289] parse!(r#"a.b.c['item']."d"[5].e['s'].f[1+2]"#) = Expr {
    kind: Query(
        AstNode {
            node: Query {
                set: AstNode {
                    node: Expr(
                        Expr {
                            kind: Path(
                                AstNode {
                                    node: Path {
                                        root: Expr {
                                            kind: VarRef(
                                                AstNode {
                                                    node: VarRef {
                                                        name: SymbolPrimitive {
                                                            value: "a",
                                                            case: Some(
                                                                CaseInsensitive,
                                                            ),
                                                        },
                                                        qualifier: Unqualified,
                                                    },
                                                    location: Some(
                                                        Location {
                                                            start: BytePosition(
                                                                ByteOffset(
                                                                    0,
                                                                ),
                                                            ),
                                                            end: BytePosition(
                                                                ByteOffset(
                                                                    1,
                                                                ),
                                                            ),
                                                        },
                                                    ),
                                                },
                                            ),
                                        },
                                        steps: [
                                            PathExpr(
                                                PathExpr {
                                                    index: Expr {
                                                        kind: VarRef(
                                                            AstNode {
                                                                node: VarRef {
                                                                    name: SymbolPrimitive {
                                                                        value: "f",
                                                                        case: Some(
                                                                            CaseInsensitive,
                                                                        ),
                                                                    },
                                                                    qualifier: Unqualified,
                                                                },
                                                                location: Some(
                                                                    Location {
                                                                        start: BytePosition(
                                                                            ByteOffset(
                                                                                28,
                                                                            ),
                                                                        ),
                                                                        end: BytePosition(
                                                                            ByteOffset(
                                                                                29,
                                                                            ),
                                                                        ),
                                                                    },
                                                                ),
                                                            },
                                                        ),
                                                    },
                                                },
                                            ),
                                            PathExpr(
                                                PathExpr {
                                                    index: Expr {
                                                        kind: BinOp(
                                                            AstNode {
                                                                node: BinOp {
                                                                    kind: Add,
                                                                    lhs: Expr {
                                                                        kind: Lit(
                                                                            AstNode {
                                                                                node: Int64Lit(
                                                                                    1,
                                                                                ),
                                                                                location: Some(
                                                                                    Location {
                                                                                        start: BytePosition(
                                                                                            ByteOffset(
                                                                                                30,
                                                                                            ),
                                                                                        ),
                                                                                        end: BytePosition(
                                                                                            ByteOffset(
                                                                                                31,
                                                                                            ),
                                                                                        ),
                                                                                    },
                                                                                ),
                                                                            },
                                                                        ),
                                                                    },
                                                                    rhs: Expr {
                                                                        kind: Lit(
                                                                            AstNode {
                                                                                node: Int64Lit(
                                                                                    2,
                                                                                ),
                                                                                location: Some(
                                                                                    Location {
                                                                                        start: BytePosition(
                                                                                            ByteOffset(
                                                                                                32,
                                                                                            ),
                                                                                        ),
                                                                                        end: BytePosition(
                                                                                            ByteOffset(
                                                                                                33,
                                                                                            ),
                                                                                        ),
                                                                                    },
                                                                                ),
                                                                            },
                                                                        ),
                                                                    },
                                                                },
                                                                location: Some(
                                                                    Location {
                                                                        start: BytePosition(
                                                                            ByteOffset(
                                                                                30,
                                                                            ),
                                                                        ),
                                                                        end: BytePosition(
                                                                            ByteOffset(
                                                                                33,
                                                                            ),
                                                                        ),
                                                                    },
                                                                ),
                                                            },
                                                        ),
                                                    },
                                                },
                                            ),
                                        ],
                                    },
                                    location: Some(
                                        Location {
                                            start: BytePosition(
                                                ByteOffset(
                                                    0,
                                                ),
                                            ),
                                            end: BytePosition(
                                                ByteOffset(
                                                    34,
                                                ),
                                            ),
                                        },
                                    ),
                                },
                            ),
                        },
                    ),
                    location: Some(
                        Location {
                            start: BytePosition(
                                ByteOffset(
                                    0,
                                ),
                            ),
                            end: BytePosition(
                                ByteOffset(
                                    34,
                                ),
                            ),
                        },
                    ),
                },
                order_by: None,
                limit: None,
                offset: None,
            },
            location: Some(
                Location {
                    start: BytePosition(
                        ByteOffset(
                            0,
                        ),
                    ),
                    end: BytePosition(
                        ByteOffset(
                            34,
                        ),
                    ),
                },
            ),
        },
    ),
}

DoD

The parsed expression includes all the nodes in the hierarchy in the correct order.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant