Skip to content

Conversation

@Sl1mb0
Copy link
Contributor

@Sl1mb0 Sl1mb0 commented Nov 5, 2025

Closes #141

This creates a UdfCodeFormatter trait that allows us to format UDF code how we see fit before compiling it. A StripIndentationFormatter implementation is also provided that strips indentation from source code.

  • I've read the contributing section of the project CONTRIBUTING.md.
  • Signed CLA (if not already signed).

@Sl1mb0 Sl1mb0 requested a review from crepererum November 5, 2025 15:29
@Sl1mb0 Sl1mb0 force-pushed the tm/format-the-snake branch from e80a738 to 4b7b7e6 Compare November 5, 2025 16:18
Base automatically changed from tm/format-the-snake to main November 5, 2025 17:22
@crepererum
Copy link
Collaborator

I think this needs a clean rebase

@Sl1mb0 Sl1mb0 force-pushed the tm/really-format-the-snake branch from 41ea1b4 to 7eab741 Compare November 6, 2025 13:29
#[tokio::test(flavor = "multi_thread")]
async fn test_strip_indentation_empty_lines_not_indented() {
let query = r#"
CREATE FUNCTION add_one()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact that the empty line is indented or not is impossible to see in this diff. I suggest that for the indentation tests you don't use multi-line strings but rather an array like this:

let query = &[
    "CREATE FUNCTION add_one()",
    // or
    "    CREATE FUNCTION add_one()",
    ...
    // this is an non-indended empty line:
    "",
    // and this one would be indended:
    "    ",
];

}

/// Default implementation that returns code unchanged
#[derive(Debug, Clone, Copy)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For both it probably also makes sense to derive Default

@Sl1mb0 Sl1mb0 requested a review from crepererum November 10, 2025 19:43
@Sl1mb0 Sl1mb0 force-pushed the tm/really-format-the-snake branch from 6280c11 to 250ee6a Compare November 11, 2025 14:41
@Sl1mb0 Sl1mb0 enabled auto-merge November 11, 2025 14:42
@Sl1mb0 Sl1mb0 added this pull request to the merge queue Nov 11, 2025
Any commits made after this event will not be merged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python Source Code & Indention

3 participants