@@ -73,7 +73,49 @@ impl<'a> TableScan<'a> {
7373 ///
7474 /// # Example
7575 /// ```
76- /// let scanner = table.new_scan().project(&[0, 2, 3])?.create_log_scanner();
76+ /// # use fluss::client::FlussConnection;
77+ /// # use fluss::config::Config;
78+ /// # use fluss::error::Result;
79+ /// # use fluss::metadata::{DataTypes, Schema, TableDescriptor, TablePath};
80+ /// # use fluss::row::InternalRow;
81+ /// # use std::time::Duration;
82+ ///
83+ /// # pub async fn example() -> Result<()> {
84+ /// let mut config = Config::default();
85+ /// config.bootstrap_server = Some("127.0.0.1:9123".to_string());
86+ /// let conn = FlussConnection::new(config).await?;
87+ ///
88+ /// let table_descriptor = TableDescriptor::builder()
89+ /// .schema(
90+ /// Schema::builder()
91+ /// .column("col1", DataTypes::int())
92+ /// .column("col2", DataTypes::string())
93+ /// .column("col3", DataTypes::string())
94+ /// .column("col3", DataTypes::string())
95+ /// .build()?,
96+ /// ).build()?;
97+ /// let table_path = TablePath::new("fluss".to_owned(), "rust_test_long".to_owned());
98+ /// let admin = conn.get_admin().await?;
99+ /// admin.create_table(&table_path, &table_descriptor, true)
100+ /// .await?;
101+ /// let table_info = admin.get_table(&table_path).await?;
102+ /// let table = conn.get_table(&table_path).await?;
103+ ///
104+ /// // Project columns by indices
105+ /// let scanner = table.new_scan().project(&[0, 2, 3])?.create_log_scanner()?;
106+ /// let scan_records = scanner.poll(Duration::from_secs(10)).await?;
107+ /// for record in scan_records {
108+ /// let row = record.row();
109+ /// println!(
110+ /// "{{{}, {}, {}}}@{}",
111+ /// row.get_int(0),
112+ /// row.get_string(2),
113+ /// row.get_string(3),
114+ /// record.offset()
115+ /// );
116+ /// }
117+ /// # Ok(())
118+ /// # }
77119 /// ```
78120 pub fn project ( mut self , column_indices : & [ usize ] ) -> Result < Self > {
79121 if column_indices. is_empty ( ) {
@@ -107,7 +149,47 @@ impl<'a> TableScan<'a> {
107149 ///
108150 /// # Example
109151 /// ```
110- /// let scanner = table.new_scan().project_by_name(&["col1", "col3"])?.create_log_scanner();
152+ /// # use fluss::client::FlussConnection;
153+ /// # use fluss::config::Config;
154+ /// # use fluss::error::Result;
155+ /// # use fluss::metadata::{DataTypes, Schema, TableDescriptor, TablePath};
156+ /// # use fluss::row::InternalRow;
157+ /// # use std::time::Duration;
158+ ///
159+ /// # pub async fn example() -> Result<()> {
160+ /// let mut config = Config::default();
161+ /// config.bootstrap_server = Some("127.0.0.1:9123".to_string());
162+ /// let conn = FlussConnection::new(config).await?;
163+ ///
164+ /// let table_descriptor = TableDescriptor::builder()
165+ /// .schema(
166+ /// Schema::builder()
167+ /// .column("col1", DataTypes::int())
168+ /// .column("col2", DataTypes::string())
169+ /// .column("col3", DataTypes::string())
170+ /// .build()?,
171+ /// ).build()?;
172+ /// let table_path = TablePath::new("fluss".to_owned(), "rust_test_long".to_owned());
173+ /// let admin = conn.get_admin().await?;
174+ /// admin.create_table(&table_path, &table_descriptor, true)
175+ /// .await?;
176+ /// let table_info = admin.get_table(&table_path).await?;
177+ /// let table = conn.get_table(&table_path).await?;
178+ ///
179+ /// // Project columns by column names
180+ /// let scanner = table.new_scan().project_by_name(&["col1", "col3"])?.create_log_scanner()?;
181+ /// let scan_records = scanner.poll(Duration::from_secs(10)).await?;
182+ /// for record in scan_records {
183+ /// let row = record.row();
184+ /// println!(
185+ /// "{{{}, {}}}@{}",
186+ /// row.get_int(0),
187+ /// row.get_string(1),
188+ /// record.offset()
189+ /// );
190+ /// }
191+ /// # Ok(())
192+ /// # }
111193 /// ```
112194 pub fn project_by_name ( mut self , column_names : & [ & str ] ) -> Result < Self > {
113195 if column_names. is_empty ( ) {
0 commit comments