You can translate the question and the replies:

Can Denodo Java custom policy Stop query and prompt customized error message?

Hi team, we want to apply custom policy to achieve a requirement: if user query some view without specified filters , we need to cancel their query and propmt customised error message like "need to input filters with columns XXXX" can you confirm, does custom policy can customized the returned error message and cancel the query at the same time? Please note, the obligatory parameters is not suitable for us, that is why we think about custom policy. Thanks Hi team, waiting for your update and advise, thanks.
user
07-07-2023 06:04:43 -0400
code

3 Answers

Hi, With [custom view policy](https://community.denodo.com/docs/html/browse/8.0/en/vdp/developer/custom_policies/developing_a_custom_policy), you can write custom error messages into the Virtual DataPort server logs, but there is currently no option to return the custom error message to the client application that called the query. For the custom error message in the logs, you can implement this by invoking the `log(...)` method, where the logs are written in the `vdp.log` file located inside `<DENODO_HOME>\logs\vdp` folder. You can check a sample custom view policy located in the folder `<DENODO_HOME>\samples\vdp\customPolicies` for reference. Another option you can consider is by using view parameters. You can add a parameter to your view without any default value so that when a user queries this view without specifying the parameter value, it will throw an error with message like: *"The following fields are obligatory in the view '<viewname>': <fieldname>"* You can learn more about this functionality in the documentation [Parameters of Derived Views](https://community.denodo.com/docs/html/browse/8.0/en/vdp/administration/creating_derived_views/creating_selection_views/creating_selection_views#parameters-of-derived-views). Hope this helps!
Denodo Team
11-07-2023 07:57:55 -0400
code
Thanks for the suggestion. Obligatory parameters are not suitable for us currently. Another thing is when I build customer policy, if the query does not hit the rule, I want to add filters like "1=2", but I found the query will not send to underlying, it stopped by denodo, is it possible to let this kind no-data-returned query can be sent to underlying db like oracle or other dbs, we just want to use the query log in underlying to get the information that query does not hit the rule so return null data. Is it related with some configuration in VDp side?
user
13-07-2023 10:37:05 -0400
Hi, Queries with filters like “1=2” are not processed by the Virtual DataPort server because it detects that the condition is incompatible and does not execute the view to save on resources. If you look into the details of a query like this, you can see that it creates a “Void Plan” in the execution trace with INCOMPATIBLE_QUERY_VIEW state. If you would like to log all the queries sent to the Virtual DataPort server regardless of the result of the policies applied on the underlying views, you can use the [Denodo Monitor](https://community.denodo.com/docs/html/browse/8.0/en/vdp/administration/monitoring_the_virtual_dataport_server/denodo_monitor/denodo_monitor). The logs generated by the tool can be stored either into a filesystem as a text file or into a database. You can explore more about storing the logs into a database in the [JDBC Logging Configuration](https://community.denodo.com/docs/html/browse/8.0/en/vdp/administration/monitoring_the_virtual_dataport_server/denodo_monitor/configuring_the_denodo_monitor#jdbc-logging-configuration) documentation. Hope this helps!
Denodo Team
17-07-2023 03:31:22 -0400
code
You must sign in to add an answer. If you do not have an account, you can register here