{"record":{"id":"dad749faaa8cee98","repo":"pentaho/pentaho-kettle","slug":"no-fields-defined-to-load-to-database","errorCode":null,"errorMessage":"No fields defined to load to database","messagePattern":"No fields defined to load to database","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/gp-bulk-loader/core/src/main/java/org/pentaho/di/trans/steps/gpbulkloader/GPBulkLoader.java","lineNumber":165,"sourceCode":"    if ( loadAction.equalsIgnoreCase( \"truncate\" ) ) {\n      contents.append( loadAction + \" \" );\n      contents.append( tableName + \";\" );\n      contents.append( Const.CR );\n    }\n    contents.append( \"\\\\COPY \" );\n    // Table name\n\n    contents.append( tableName );\n\n    // Names of columns\n\n    contents.append( \" ( \" );\n\n    String[] streamFields = meta.getFieldStream();\n    String[] tableFields = meta.getFieldTable();\n\n    if ( streamFields == null || streamFields.length == 0 ) {\n      throw new KettleException( \"No fields defined to load to database\" );\n    }\n\n    for ( int i = 0; i < streamFields.length; i++ ) {\n      if ( i != 0 ) {\n        contents.append( \", \" );\n      }\n      contents.append( dm.quoteField( tableFields[i] ) );\n    }\n\n    contents.append( \" ) \" );\n\n    // The \"FROM\" filename\n    contents.append( \" FROM \" );\n    contents.append( inputName );\n\n    // The \"FORMAT\" clause\n    contents.append( \" WITH CSV \" );\n","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/gp-bulk-loader/core/src/main/java/org/pentaho/di/trans/steps/gpbulkloader/GPBulkLoader.java#L147-L183","documentation":"GPBulkLoader.getControlFileContents throws a KettleException 'No fields defined to load to database' when building the gpload control file but the step's field stream mapping is null or empty. The generated LOAD control file must list at least one column; an empty mapping would produce invalid SQL.","triggerScenarios":"createControlFile runs (during step initialization) with meta.getFieldStream() null or length 0 — the Fields table in the GP Bulk Loader dialog was never populated, or 'Get Fields' was never invoked after changing upstream steps.","commonSituations":"User filled in the target table but forgot the field mapping tab; transformation copied where the mapping failed to persist; all upstream fields removed after configuration so mapping became empty.","solutions":["Open the GP Bulk Loader step dialog, go to the Fields tab and click 'Get Fields' to populate the mapping.","Manually add stream-field-to-table-column entries in the Fields table.","Verify upstream steps still emit fields, then re-run 'Get Fields'.","Save the transformation after mapping so the fields persist."],"exampleFix":"// before: fields table empty in dialog\nString[] streamFields = {}; // -> KettleException\n\n// after: populate mapping (in step dialog) or programmatically\nmeta.setFieldStream( new String[] { \"id\", \"name\" } );\nmeta.setFieldTable( new String[] { \"id\", \"name\" } );","handlingStrategy":"validation","validationCode":"// before executing, confirm the field mapping exists\nif ( meta.getFieldStream() == null || meta.getFieldStream().length == 0 ) {\n  throw new KettleException( \"GP Bulk Loader has no field mapping configured\" );\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always click 'Get Fields' in the Fields tab after configuring the step","Verify the mapping survives save/reopen of the transformation","Confirm upstream steps emit fields before configuring the loader"],"tags":["mapping","config","greenplum"],"backgroundTag":"missing-required-config-field","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}