You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exportconst PyBranches ="# Fork an isolated, writable branch from main.\n# The returned handle is scoped to the branch; writes on it do not\n# affect main.\nbranch = table.branches.create(\"exp\")\nbranch.add([{\"vector\": [10.0, 11.0], \"item\": \"baz\", \"price\": 30.0}])\nprint(branch.count_rows()) # 3 rows on the branch\nprint(table.count_rows()) # main is still untouched\n\n# List all branches on the table.\nprint(table.branches.list())\n\n# Reopen the branch later by name.\ncheckedOut = table.branches.checkout(\"exp\")\n\n# Or open a branch directly from the database connection.\nbranch_handle = db.open_table(\"quotes_versioning_example\", branch=\"exp\")\n\n# Delete a branch when you're done with it.\ntable.branches.delete(\"exp\")\n";
@@ -140,6 +142,8 @@ export const TsAlterColumnsWithExpression = "// For custom transforms, create a
140
142
141
143
export const TsAlterVectorColumn = "const oldDim = 384;\nconst newDim = 1024;\nconst vectorSchema = new arrow.Schema([\n new arrow.Field(\"id\", new arrow.Int64()),\n new arrow.Field(\n \"embedding\",\n new arrow.FixedSizeList(\n oldDim,\n new arrow.Field(\"item\", new arrow.Float16(), true),\n ),\n true,\n ),\n]);\nconst vectorData = lancedb.makeArrowTable(\n [{ id: 1, embedding: Array.from({ length: oldDim }, () => Math.random()) }],\n { schema: vectorSchema },\n);\nconst vectorTable = await db.createTable(\"vector_alter_example\", vectorData, {\n mode: \"overwrite\",\n});\n\n// Changing FixedSizeList dimensions (384 -> 1024) is not supported via alterColumns.\n// Use addColumns + dropColumns + alterColumns(rename) to replace the column.\nawait vectorTable.addColumns([\n {\n name: \"embedding_v2\",\n valueSql: `arrow_cast(NULL, 'FixedSizeList(${newDim}, Float16)')`,\n },\n]);\nawait vectorTable.dropColumns([\"embedding\"]);\nawait vectorTable.alterColumns([{ path: \"embedding_v2\", rename: \"embedding\" }]);\n";
142
144
145
+
exportconst TsBranches ="const branches = await table.branches();\n\n// Fork an isolated, writable branch from main.\n// The returned handle is scoped to the branch; writes on it do not\n// affect main.\nconst branch = await branches.create(\"exp\");\nawait branch.add([{ id: 2, author: \"Morty\", quote: \"Aww geez, Rick!\" }]);\n\n// List all branches on the table.\nconsole.log(await branches.list());\n\n// Reopen the branch later by name.\nconst checkedOut = await branches.checkout(\"exp\");\n\n// Or open a branch directly from the database connection.\nconst branchHandle = await db.openTable(\n\"quotes_versioning_example\",\n undefined,\n { branch: \"exp\" },\n);\n\n// Delete a branch when you're done with it.\nawait branches.delete(\"exp\");\n";
exportconst RsBranches ="use lance::dataset::refs::Ref;\n\n// Fork an isolated, writable branch from main's latest version.\n// The returned handle is scoped to the branch; writes on it do not\n// affect main.\nlet branch = table\n .create_branch(\"exp\", Ref::Version(None, None))\n .await\n .unwrap();\nbranch.add(make_quotes_reader(vec![(4, \"Morty\", \"Aww geez, Rick!\")]))\n .execute()\n .await\n .unwrap();\n\n// List all branches on the table.\nlet branches = table.list_branches().await.unwrap();\nprintln!(\"Branches: {:?}\", branches);\n\n// Reopen the branch later by name, or open it directly via the builder.\nlet _checked_out = table.checkout_branch(\"exp\").await.unwrap();\nlet _opened = db\n .open_table(\"quotes_versioning_example\")\n .branch(\"exp\")\n .execute()\n .await\n .unwrap();\n\n// Delete a branch when you're done with it.\ntable.delete_branch(\"exp\").await.unwrap();\n";
0 commit comments