()
| 1747 | |
| 1748 | #[tokio::test] |
| 1749 | async fn register_table() -> Result<()> { |
| 1750 | let df = test_table().await?.select_columns(&["c1", "c12"])?; |
| 1751 | let ctx = SessionContext::new(); |
| 1752 | let df_impl = DataFrame::new(ctx.state(), df.logical_plan().clone()); |
| 1753 | |
| 1754 | // register a dataframe as a table |
| 1755 | let table_provider = df_impl.clone().into_view(); |
| 1756 | assert_eq!(table_provider.table_type(), TableType::View); |
| 1757 | ctx.register_table("test_table", table_provider)?; |
| 1758 | |
| 1759 | // pull the table out |
| 1760 | let table = ctx.table("test_table").await?; |
| 1761 | |
| 1762 | let group_expr = vec![col("c1")]; |
| 1763 | let aggr_expr = vec![sum(col("c12"))]; |
| 1764 | |
| 1765 | // check that we correctly read from the table |
| 1766 | let df_results = df_impl |
| 1767 | .aggregate(group_expr.clone(), aggr_expr.clone())? |
| 1768 | .collect() |
| 1769 | .await?; |
| 1770 | let table_results = &table.aggregate(group_expr, aggr_expr)?.collect().await?; |
| 1771 | |
| 1772 | assert_snapshot!( |
| 1773 | batches_to_sort_string(&df_results), |
| 1774 | @r" |
| 1775 | +----+-----------------------------+ |
| 1776 | | c1 | sum(aggregate_test_100.c12) | |
| 1777 | +----+-----------------------------+ |
| 1778 | | a | 10.238448667882977 | |
| 1779 | | b | 7.797734760124923 | |
| 1780 | | c | 13.860958726523545 | |
| 1781 | | d | 8.793968289758968 | |
| 1782 | | e | 10.206140546981722 | |
| 1783 | +----+-----------------------------+ |
| 1784 | " |
| 1785 | ); |
| 1786 | |
| 1787 | // the results are the same as the results from the view, modulo the leaf table name |
| 1788 | assert_snapshot!( |
| 1789 | batches_to_sort_string(table_results), |
| 1790 | @r" |
| 1791 | +----+---------------------+ |
| 1792 | | c1 | sum(test_table.c12) | |
| 1793 | +----+---------------------+ |
| 1794 | | a | 10.238448667882977 | |
| 1795 | | b | 7.797734760124923 | |
| 1796 | | c | 13.860958726523545 | |
| 1797 | | d | 8.793968289758968 | |
| 1798 | | e | 10.206140546981722 | |
| 1799 | +----+---------------------+ |
| 1800 | " |
| 1801 | ); |
| 1802 | Ok(()) |
| 1803 | } |
| 1804 | |
| 1805 | #[tokio::test] |
| 1806 | async fn register_temporary_table() -> Result<()> { |
nothing calls this directly
no test coverage detected
searching dependent graphs…