how to print sql query of view in runtime
The Devel module provides a SQL query log for debugging/performance testing. You can enable this under Configuration > Development > Devel settings (/admin/config/development/devel) and by setting Display query log option.



Once enabled, the bottom of the page will contain all SQL queries executed in page rendering. For your needs, you'll need to look for views_plugin_query_default::execute function calls (the where column) to see the SQL query executed for your view.