func TestTableManager_noAlterMissingTagTableTag(t *testing.T) {
	p := newPostgresqlTest(t)
	p.TagsAsForeignKeys = true
	p.TagTableAddColumnTemplates = []*sqltemplate.Template{}
	require.NoError(t, p.Connect())

	metrics := []telegraf.Metric{
		newMetric(t, "", MSS{"tag": "foo"}, MSI{"a": 1}),
	}
	tsrc := NewTableSources(p.Postgresql, metrics)[t.Name()]
	require.NoError(t, p.tableManager.MatchSource(ctx, p.db, tsrc))

	metrics = []telegraf.Metric{
		newMetric(t, "", MSS{"tag": "foo"}, MSI{"a": 2}),
		newMetric(t, "", MSS{"tag": "foo", "bar": "baz"}, MSI{"a": 3}),
	}
	tsrc = NewTableSources(p.Postgresql, metrics)[t.Name()]
	ttsrc := NewTagTableSource(tsrc)
	require.NoError(t, p.tableManager.MatchSource(ctx, p.db, tsrc))
	assert.NotContains(t, ttsrc.ColumnNames(), "bar")
}
// Verify that when alter statements are disabled with foreign tags and a metric comes in with a new tag key, that the
// field is omitted.
Verify that when alter statements are disabled with foreign tags and a metric comes in with a new tag key, that the
field is omitted.
// Verify that when alter statements are disabled with foreign tags and a metric comes in with a new tag key that the // field is omitted .
func TestTableManager_noAlterMissingTagTableTag(t *testing.T) {
	p := newPostgresqlTest(t)
	p.TagsAsForeignKeys = true
	p.TagTableAddColumnTemplates = []*sqltemplate.Template{}
	require.NoError(t, p.Connect())
	metrics := []telegraf.Metric{
		newMetric(t, "", MSS{"tag": "foo"}, MSI{"a": 1}),
	}
	tsrc := NewTableSources(p.Postgresql, metrics)[t.Name()]
	require.NoError(t, p.tableManager.MatchSource(ctx, p.db, tsrc))
	metrics = []telegraf.Metric{
		newMetric(t, "", MSS{"tag": "foo"}, MSI{"a": 2}),
		newMetric(t, "", MSS{"tag": "foo", "bar": "baz"}, MSI{"a": 3}),
	}
	tsrc = NewTableSources(p.Postgresql, metrics)[t.Name()]
	ttsrc := NewTagTableSource(tsrc)
	require.NoError(t, p.tableManager.MatchSource(ctx, p.db, tsrc))
	assert.NotContains(t, ttsrc.ColumnNames(), "bar")
}
func TestTableManager_noAlterMissingTagTableTag ( t * testing . T ) { p := newPostgresqlTest ( t ) p . TagsAsForeignKeys = true p . TagTableAddColumnTemplates = [ ] * sqltemplate . Template { } require . NoError ( t , p . Connect ( ) ) metrics := [ ] telegraf . Metric { newMetric ( t , " " , MSS { " " : " " } , MSI { " " : 1 } ) , } tsrc := NewTableSources ( p . Postgresql , metrics ) [ t . Name ( ) ] require . NoError ( t , p . tableManager . MatchSource ( ctx , p . db , tsrc ) ) metrics = [ ] telegraf . Metric { newMetric ( t , " " , MSS { " " : " " } , MSI { " " : 2 } ) , newMetric ( t , " " , MSS { " " : " " , " " : " " } , MSI { " " : 3 } ) , } tsrc = NewTableSources ( p . Postgresql , metrics ) [ t . Name ( ) ] ttsrc := NewTagTableSource ( tsrc ) require . NoError ( t , p . tableManager . MatchSource ( ctx , p . db , tsrc ) ) assert . NotContains ( t , ttsrc . ColumnNames ( ) , " " ) }
Verify that when alter statements are disabled with foreign tags and a metric comes in with a new tag key, that the
field is omitted.
Verify that when alter statements are disabled with foreign tags and a metric comes in with a new tag key that the field is omitted .