In my python code that generates mxd files, I changed the name of one of my table views from 'Organizations' to 'Organization' and later discovered that the table view's definition query became blank with that change. To make it even stranger, this only happens if arcpy.env.workspace is set to my enterprise database (None and a file geodatabase work OK). I expect I'll have to open a problem with ESRI, but thought I'd log it here in case anybody else stumbles on it. This is a very severe error for me since the definition query filters sensitive data out of the view - at least when it is working as designed. An obvious workaround is to name it something other than "Organization" but it does shake my confidence that I can trust that the sensitive data will always get filtered out appropriately.
Here is the test code that reproduces the problem
<SPAN class="keyword token">import</SPAN> os
<SPAN class="keyword token">import</SPAN> arcpy
DB_PATH <SPAN class="operator token">=</SPAN> r<SPAN class="string token">'C:/Users/dmorri28/Documents/ArcGIS/Projects/MyProject/CC-SQL2k16-ERC-SDE.sde'</SPAN>
DB_TABLE <SPAN class="operator token">=</SPAN> os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>join<SPAN class="punctuation token">(</SPAN>DB_PATH<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'ROW_Habitat.SDE.Program'</SPAN><SPAN class="punctuation token">)</SPAN>
TITLES <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'DummyTitle'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'Organization'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'Org'</SPAN><SPAN class="punctuation token">]</SPAN>
WORKSPACES <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>None<SPAN class="punctuation token">,</SPAN> DB_PATH<SPAN class="punctuation token">,</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>scratchWorkspace<SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">def</SPAN> run_test <SPAN class="punctuation token">(</SPAN>workspace<SPAN class="punctuation token">,</SPAN> title<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">'***********************************'</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">'Workspace: %s'</SPAN> <SPAN class="operator token">%</SPAN> workspace<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">'Title: %s'</SPAN><SPAN class="operator token">%</SPAN> title<SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> workspace
arcpy<SPAN class="punctuation token">.</SPAN>MakeTableView_management<SPAN class="punctuation token">(</SPAN>DB_TABLE<SPAN class="punctuation token">,</SPAN> title<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"Org_ID = 'FM'"</SPAN><SPAN class="punctuation token">)</SPAN>
table_view <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>TableView<SPAN class="punctuation token">(</SPAN>title<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Table view query: %s"</SPAN> <SPAN class="operator token">%</SPAN> <SPAN class="punctuation token">(</SPAN>str<SPAN class="punctuation token">(</SPAN>table_view<SPAN class="punctuation token">.</SPAN>definitionQuery<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>Delete_management<SPAN class="punctuation token">(</SPAN>title<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'TableView'</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">if</SPAN> __name__ <SPAN class="operator token">==</SPAN> <SPAN class="string token">'__main__'</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">for</SPAN> workspace <SPAN class="keyword token">in</SPAN> WORKSPACES<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">for</SPAN> title <SPAN class="keyword token">in</SPAN> TITLES<SPAN class="punctuation token">:</SPAN>
run_test<SPAN class="punctuation token">(</SPAN>workspace<SPAN class="punctuation token">,</SPAN> title<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Here is the output - notice how on the fifth test the query is empty.
***********************************
Workspace: None
Title: DummyTitle
Table view query: Org_ID = 'FM'
***********************************
Workspace: None
Title: Organization
Table view query: Org_ID = 'FM'
***********************************
Workspace: None
Title: Org
Table view query: Org_ID = 'FM'
***********************************
Workspace: C:/Users/dmorri28/Documents/ArcGIS/Projects/MyProject/CC-SQL2k16-ERC-SDE.sde
Title: DummyTitle
Table view query: Org_ID = 'FM'
***********************************
Workspace: C:/Users/dmorri28/Documents/ArcGIS/Projects/MyProject/CC-SQL2k16-ERC-SDE.sde
Title: Organization
Table view query:
***********************************
Workspace: C:/Users/dmorri28/Documents/ArcGIS/Projects/MyProject/CC-SQL2k16-ERC-SDE.sde
Title: Org
Table view query: Org_ID = 'FM'
***********************************
Workspace: None
Title: DummyTitle
Table view query: Org_ID = 'FM'
***********************************
Workspace: None
Title: Organization
Table view query: Org_ID = 'FM'
***********************************
Workspace: None
Title: Org
Table view query: Org_ID = 'FM' <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
I was able to reproduce this on two different systems. I'm running this on Python 2.7. I'm also using ArcMap 10.6.1.