Skip to content

Pull out scalar UDTF code into snippets#202

Merged
dantasse merged 5 commits intomainfrom
dantasse/scalar_udtfs_snippets
Apr 6, 2026
Merged

Pull out scalar UDTF code into snippets#202
dantasse merged 5 commits intomainfrom
dantasse/scalar_udtfs_snippets

Conversation

@dantasse
Copy link
Copy Markdown
Contributor

@dantasse dantasse commented Apr 3, 2026

The Scalar UDTF page has already gotten a little out of date. This PR pulls the code into tested snippets so that syntax errors don't happen, at least.

@mintlify
Copy link
Copy Markdown
Contributor

mintlify bot commented Apr 3, 2026

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
lancedb-bcbb4faf 🟢 Ready View Preview Apr 3, 2026, 8:34 PM

| **Parallelism** | Fragment-parallel | Fragment-parallel | Partition-parallel |
| **Inherited columns** | N/A — adds to existing rows | Automatic from query | Independent output schema |
| **Registration** | `table.add_columns()` | `db.create_materialized_view(udtf=)` | `db.create_udtf_view()` |
| **Registration** | [`table.add_columns()`](https://lancedb.github.io/geneva/api/table/#geneva.table.Table.add_columns) | [`db.create_scalar_udtf_view()`](https://lancedb.github.io/geneva/api/connection/#geneva.db.Connection.create_scalar_udtf_view) | [`db.create_udtf_view()`](https://lancedb.github.io/geneva/api/connection/#geneva.db.Connection.create_udtf_view) |
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The main thing that changed in this PR is that now you use create_scalar_udtf_view() instead of create_materialized_view(udtf=) to make a scalar UDTF.

I couldn't actually pull these out to their own snippets because they're in table cells, but I did add test_geneva_udfs_index just so a test will fail if we change one of these methods' names.

(I also added links just for convenience)

```
<CodeGroup>
<CodeBlock filename="Python" language="python" icon="python">
{PyScalarUdtfIterator}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this code is now in tests/py/test_geneva_scalar_udtfs.py; similarly to all the rest of this file



# TODO: remove skip once geneva 0.12.0 is on PyPI (head node defaults changed to 4 CPU / 8Gi)
@pytest.mark.skip(reason="requires geneva>=0.12.0")
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yay, while I was here I remembered to do this

mock_conn = MagicMock()
import geneva
from unittest.mock import MagicMock, create_autospec
mock_conn = create_autospec(geneva.db.Connection, instance=True)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, here's the important thing: MagicMocks let you call anything with any params... defeating the point of the test! But create_autospec will fail if the methods or params don't exist. So, updated this here.

@@ -0,0 +1,311 @@
# SPDX-License-Identifier: Apache-2.0
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No code has changed, this is just all the snippets + setup around them.

=======
"Pillow>=12.1.1",
>>>>>>> Stashed changes
"geneva>=0.12.0",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated this and the uv.lock bc I guess it had previously gotten committed mid-rebase

@dantasse dantasse merged commit b2aab77 into main Apr 6, 2026
2 checks passed
@dantasse dantasse deleted the dantasse/scalar_udtfs_snippets branch April 6, 2026 19:30
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.

1 participant