(
catalog: impl SessionCatalog,
mut stmt: CreateTableFromSourceStatement<Aug>,
storage_configuration: &StorageConfiguration,
)
| 1757 | } |
| 1758 | |
| 1759 | async fn purify_create_table_from_source( |
| 1760 | catalog: impl SessionCatalog, |
| 1761 | mut stmt: CreateTableFromSourceStatement<Aug>, |
| 1762 | storage_configuration: &StorageConfiguration, |
| 1763 | ) -> Result<PurifiedStatement, PlanError> { |
| 1764 | let scx = StatementContext::new(None, &catalog); |
| 1765 | let CreateTableFromSourceStatement { |
| 1766 | name: _, |
| 1767 | columns, |
| 1768 | constraints, |
| 1769 | source: source_name, |
| 1770 | if_not_exists: _, |
| 1771 | external_reference, |
| 1772 | format, |
| 1773 | envelope, |
| 1774 | include_metadata: _, |
| 1775 | with_options, |
| 1776 | } = &mut stmt; |
| 1777 | |
| 1778 | // Columns and constraints cannot be specified by the user but will be populated below. |
| 1779 | if matches!(columns, TableFromSourceColumns::Defined(_)) { |
| 1780 | sql_bail!("CREATE TABLE .. FROM SOURCE column definitions cannot be specified directly"); |
| 1781 | } |
| 1782 | if !constraints.is_empty() { |
| 1783 | sql_bail!( |
| 1784 | "CREATE TABLE .. FROM SOURCE constraint definitions cannot be specified directly" |
| 1785 | ); |
| 1786 | } |
| 1787 | |
| 1788 | // Get the source item |
| 1789 | let item = match scx.get_item_by_resolved_name(source_name) { |
| 1790 | Ok(item) => item, |
| 1791 | Err(e) => return Err(e), |
| 1792 | }; |
| 1793 | |
| 1794 | // Ensure it's an ingestion-based and alterable source. |
| 1795 | let desc = match item.source_desc()? { |
| 1796 | Some(desc) => desc.clone().into_inline_connection(scx.catalog), |
| 1797 | None => { |
| 1798 | sql_bail!("cannot ALTER this type of source") |
| 1799 | } |
| 1800 | }; |
| 1801 | let unresolved_source_name: UnresolvedItemName = source_name.full_item_name().clone().into(); |
| 1802 | |
| 1803 | let crate::plan::statement::ddl::TableFromSourceOptionExtracted { |
| 1804 | text_columns, |
| 1805 | exclude_columns, |
| 1806 | retain_history: _, |
| 1807 | details, |
| 1808 | partition_by: _, |
| 1809 | seen: _, |
| 1810 | } = with_options.clone().try_into()?; |
| 1811 | if details.is_some() { |
| 1812 | sql_bail!("DETAILS option cannot be explicitly set"); |
| 1813 | } |
| 1814 | |
| 1815 | // Our text column values are unqualified (just column names), but the purification methods below |
| 1816 | // expect to match the fully-qualified names against the full set of tables in upstream, so we |
no test coverage detected