<entity name="tw_tweet_user_merged" query="select * from tw_tweet_user_merged">
<field column="id" name="id" />
<field column="gender" name="gender" />
<entity name="tw_flag" query="select moderator_id from tw_flag where tweet_id='${tw_tweet_user_merged.id}'">
<field column="moderator_id" name="moderator_id" />
</entity>
</entity>
This is my DIH data-config.xml,
It is importing id, user_id but not uid,
flagged_by in schema.xml is
<field name="moderator_id" type="text_general" indexed="true" stored="true" required="false" multiValued="true"/>
I believe that you have column and name reversed in your config.
You can also get rid of the field config and do the name changing in the SQL:
select uid as flagged_by from flag where tweet_id='${tweets.id}'