Integration / Apache NiFi Interview Questions
What is the PutDatabaseRecord processor and how does it differ from ExecuteSQL?
PutDatabaseRecord writes structured records from a FlowFile into a relational database table using JDBC. It is the write counterpart to QueryDatabaseTable and ExecuteSQL. Unlike ExecuteSQL — which executes arbitrary SQL statements — PutDatabaseRecord works with the NiFi record model: it reads records from the FlowFile using a RecordReader and generates INSERT, UPSERT, INSERT_IGNORE, UPDATE, or DELETE statements automatically based on the target table schema.
Key configuration properties:
Record Reader: Parses the FlowFile content (JsonTreeReader, CSVReader, AvroReader, etc.).
Statement Type: INSERT, UPDATE, INSERT_OR_UPDATE (upsert), INSERT_IGNORE (ignore on key conflict), DELETE, or USE_ATTR_TYPE (pick from a FlowFile attribute).
Database Connection Pooling Service: A DBCPConnectionPool reference.
Table Name: Static name or EL expression like ${target.table}.
Translate Field Names: When enabled, converts record field names (e.g., camelCase) to database column name conventions (e.g., snake_case).
The advantage over ExecuteSQL for writes is that PutDatabaseRecord handles schema mapping automatically — it queries the target table's metadata to determine column types and order, then generates correct parameterized SQL. This avoids hand-crafting INSERT statements and handles type coercion automatically.
More Related questions...