@@ -112,6 +112,9 @@ type statement struct {
112112 // Field that contains the JSON string to authorize a view to source datasets
113113 authorizeViewToDatasets string
114114
115+ // Field that contains the table description to update
116+ tableDescription string
117+
115118 // Copy table fields
116119 copyTableSource string
117120 copyTableDestination string
@@ -219,6 +222,8 @@ func (st *statement) GetOption(key string) (string, error) {
219222 return st .ingestPath , nil
220223 case OptionJsonUpdateTableColumnsDescription :
221224 return st .updateTableColumnsDescription , nil
225+ case OptionStringUpdateTableDescriptionValue :
226+ return st .tableDescription , nil
222227 case OptionJsonAuthorizeViewToDatasets :
223228 return st .authorizeViewToDatasets , nil
224229 case OptionStringDataprocReqRegion :
@@ -436,6 +441,9 @@ func (st *statement) SetOption(key string, v string) error {
436441 return nil
437442 case OptionJsonAuthorizeViewToDatasets :
438443 st .authorizeViewToDatasets = v
444+ case OptionStringUpdateTableDescriptionValue :
445+ st .tableDescription = v
446+ return nil
439447 case OptionBoolQueryLinkFailedJob :
440448 val , err := strconv .ParseBool (v )
441449 if err == nil {
@@ -546,6 +554,10 @@ func (st *statement) ExecuteQuery(ctx context.Context) (array.RecordReader, int6
546554 return st .executeUpdateTableColumnsDescription (ctx )
547555 }
548556
557+ if st .tableDescription != "" {
558+ return st .executeUpdateTableDescription (ctx )
559+ }
560+
549561 if st .authorizeViewToDatasets != "" {
550562 return st .executeAuthorizeViewToDatasets (ctx )
551563 }
@@ -1636,6 +1648,7 @@ func (st *statement) executeCreateNotebookExecutionJob(ctx context.Context) (arr
16361648
16371649// executeUpdateTableColumnsDescription updates the table columns descriptions
16381650// based on the JSON string in st.updateTableColumnsDescription
1651+ // using the table reference from st.queryConfig.Dst
16391652//
16401653// The JSON string is a map of column name to description.
16411654//
@@ -1688,6 +1701,34 @@ func (st *statement) executeUpdateTableColumnsDescription(ctx context.Context) (
16881701 return emptyResult ()
16891702}
16901703
1704+ // executeUpdateTableDescription updates the table description
1705+ // using the table reference from st.queryConfig.Dst
1706+ func (st * statement ) executeUpdateTableDescription (ctx context.Context ) (array.RecordReader , int64 , error ) {
1707+ thisFunction := getFunctionName ()
1708+
1709+ if st .queryConfig .Dst == nil {
1710+ return nil , - 1 , adbcError (adbc .StatusInvalidArgument , thisFunction , "destination table not specified" )
1711+ }
1712+
1713+ table := st .cnxn .client .DatasetInProject (st .queryConfig .Dst .ProjectID , st .queryConfig .Dst .DatasetID ).Table (st .queryConfig .Dst .TableID )
1714+
1715+ // Get the current table metadata
1716+ md , err := table .Metadata (ctx )
1717+ if err != nil {
1718+ return nil , - 1 , adbcError (adbc .StatusInternal , thisFunction , fmt .Sprintf ("failed to get table metadata: %v" , err ))
1719+ }
1720+
1721+ update := bigquery.TableMetadataToUpdate {
1722+ Description : st .tableDescription ,
1723+ }
1724+ _ , err = table .Update (ctx , update , md .ETag )
1725+ if err != nil {
1726+ return nil , - 1 , adbcError (adbc .StatusInternal , thisFunction , fmt .Sprintf ("failed to update table description: %v" , err ))
1727+ }
1728+
1729+ return emptyResult ()
1730+ }
1731+
16911732func (st * statement ) executeAuthorizeViewToDatasets (ctx context.Context ) (array.RecordReader , int64 , error ) {
16921733 thisFunction := getFunctionName ()
16931734
0 commit comments