diff --git a/receiver/sqlqueryreceiver/logs_receiver_test.go b/receiver/sqlqueryreceiver/logs_receiver_test.go index 34877c23ce23..7aeb9129609c 100644 --- a/receiver/sqlqueryreceiver/logs_receiver_test.go +++ b/receiver/sqlqueryreceiver/logs_receiver_test.go @@ -51,3 +51,24 @@ func TestLogsQueryReceiver_Collect(t *testing.T) { "Observed timestamps of all log records collected in a single scrape should be equal", ) } + +func TestLogsQueryReceiver_MissingColumnInResultSetForAttributeColumn(t *testing.T) { + fakeClient := &sqlquery.FakeDBClient{ + StringMaps: [][]sqlquery.StringMap{ + {{"col1": "42"}}, + }, + } + queryReceiver := logsQueryReceiver{ + client: fakeClient, + query: sqlquery.Query{ + Logs: []sqlquery.LogsCfg{ + { + BodyColumn: "col1", + AttributeColumns: []string{"expected_column"}, + }, + }, + }, + } + _, err := queryReceiver.collect(context.Background()) + assert.ErrorContains(t, err, "rowToLog: attribute_column not found: 'expected_column'") +}