waitingkuo commented on code in PR #3455:
URL: https://github.com/apache/arrow-datafusion/pull/3455#discussion_r968905053


##########
datafusion/core/src/catalog/information_schema.rs:
##########
@@ -579,3 +613,45 @@ impl From<InformationSchemaColumnsBuilder> for MemTable {
         MemTable::try_new(schema, vec![vec![batch]]).unwrap()
     }
 }
+
+struct InformationSchemaSettingsBuilder {
+    names: StringBuilder,
+    settings: StringBuilder,
+}
+
+impl InformationSchemaSettingsBuilder {
+    fn new() -> Self {
+        Self {
+            names: StringBuilder::new(),
+            settings: StringBuilder::new(),
+        }
+    }
+
+    fn add_setting(&mut self, name: impl AsRef<str>, setting: impl AsRef<str>) 
{
+        self.names.append_value(name.as_ref());
+        self.settings.append_value(setting.as_ref());
+    }
+}
+
+impl From<InformationSchemaSettingsBuilder> for MemTable {
+    fn from(value: InformationSchemaSettingsBuilder) -> MemTable {
+        let schema = Schema::new(vec![
+            Field::new("name", DataType::Utf8, false),
+            Field::new("setting", DataType::Utf8, false),
+        ]);
+
+        let InformationSchemaSettingsBuilder {
+            mut names,
+            mut settings,
+        } = value;
+
+        let schema = Arc::new(schema);
+        let batch = RecordBatch::try_new(
+            schema.clone(),
+            vec![Arc::new(names.finish()), Arc::new(settings.finish())],
+        )
+        .unwrap();
+
+        MemTable::try_new(schema, vec![vec![batch]]).unwrap()
+    }
+}

Review Comment:
   implement `InformationSchemaSettingsBuilder`
   only two columns, `name` and `setting` supported now
   
   this is what postgresql has
   ```bash
   show all;
   
                     name                  |                                 
setting                                  |                                      
                         description                                            
                   
   
----------------------------------------+--------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------
    allow_system_table_mods                | off                                
                                      | Allows modifications of the structure 
of system tables.
    application_name                       | psql                               
                                      | Sets the application name to be 
reported in statistics and logs.
    archive_cleanup_command                |                                    
                                      | Sets the shell command that will be 
executed at every restart point.
    archive_command                        | (disabled)                         
                                      | Sets the shell command that will be 
called to archive a WAL file.
    archive_mode                           | off                                
                                      | Allows archiving of WAL files using 
archive_command.
    archive_timeout                        | 0                                  
                                      | Forces a switch 
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to