@@ -97,6 +97,7 @@ export default {
9797 ? this . columnsToSync
9898 : utils . parseObject ( this . columnsToSync ) ;
9999
100+ // Parse embeddingSourceColumns (either object[] or string[] of JSON)
100101 const embeddingSourceColumns = Array . isArray ( this . embeddingSourceColumns )
101102 ? this . embeddingSourceColumns . map ( ( item , idx ) => {
102103 if ( typeof item === "string" ) {
@@ -112,23 +113,66 @@ export default {
112113 } )
113114 : utils . parseObject ( this . embeddingSourceColumns ) ;
114115
115- if ( ! Array . isArray ( columnsToSync ) || ! columnsToSync . length ) {
116- throw new ConfigurationError (
117- "columnsToSync must be a non-empty array for DELTA_SYNC indexes." ,
118- ) ;
119- }
120- if ( ! Array . isArray ( embeddingSourceColumns ) || ! embeddingSourceColumns . length ) {
116+ // Parse embeddingVectorColumns (either object[] or string[] of JSON)
117+ const embeddingVectorColumns = Array . isArray ( this . embeddingVectorColumns )
118+ ? this . embeddingVectorColumns . map ( ( item , idx ) => {
119+ if ( typeof item === "string" ) {
120+ try {
121+ return JSON . parse ( item ) ;
122+ } catch ( e ) {
123+ throw new ConfigurationError (
124+ `embeddingVectorColumns[${ idx } ] is not valid JSON: ${ e . message } ` ,
125+ ) ;
126+ }
127+ }
128+ return item ;
129+ } )
130+ : utils . parseObject ( this . embeddingVectorColumns ) ;
131+
132+ // Require at least one embedding config: source OR vector columns
133+ const hasSource = Array . isArray ( embeddingSourceColumns ) && embeddingSourceColumns . length > 0 ;
134+ const hasVectors = Array . isArray ( embeddingVectorColumns ) && embeddingVectorColumns . length > 0 ;
135+ if ( ! hasSource && ! hasVectors ) {
121136 throw new ConfigurationError (
122- "embeddingSourceColumns must be a non-empty array for DELTA_SYNC indexes." ,
137+ "Provide either embeddingSourceColumns (compute embeddings) or embeddingVectorColumns (self-managed) for DELTA_SYNC indexes." ,
123138 ) ;
124139 }
125140
126- payload . delta_sync_index_spec = {
141+ const deltaSpec = {
127142 source_table : this . sourceTable ,
128143 pipeline_type : this . pipelineType || "TRIGGERED" ,
129- columns_to_sync : columnsToSync ,
130- embedding_source_columns : embeddingSourceColumns ,
131144 } ;
145+ if ( Array . isArray ( columnsToSync ) && columnsToSync . length > 0 ) {
146+ deltaSpec . columns_to_sync = columnsToSync ;
147+ }
148+ if ( hasSource ) {
149+ // Optional: shallow validation of required keys
150+ for ( const [
151+ i ,
152+ c ,
153+ ] of embeddingSourceColumns . entries ( ) ) {
154+ if ( ! c ?. name || ! c ?. embedding_model_endpoint_name ) {
155+ throw new ConfigurationError (
156+ `embeddingSourceColumns[${ i } ] must include "name" and "embedding_model_endpoint_name"` ,
157+ ) ;
158+ }
159+ }
160+ deltaSpec . embedding_source_columns = embeddingSourceColumns ;
161+ }
162+ if ( hasVectors ) {
163+ for ( const [
164+ i ,
165+ c ,
166+ ] of embeddingVectorColumns . entries ( ) ) {
167+ if ( ! c ?. name || typeof c ?. embedding_dimension !== "number" ) {
168+ throw new ConfigurationError (
169+ `embeddingVectorColumns[${ i } ] must include "name" and numeric "embedding_dimension"` ,
170+ ) ;
171+ }
172+ }
173+ deltaSpec . embedding_vector_columns = embeddingVectorColumns ;
174+ }
175+ payload . delta_sync_index_spec = deltaSpec ;
132176 }
133177
134178 else if ( this . indexType === "DIRECT_ACCESS" ) {
0 commit comments