Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.53k stars 2.76k forks source link

azure.mgmt.datafactory.models.RunQueryFilter not working #26558

Closed ChronosSong closed 1 year ago

ChronosSong commented 1 year ago

I query the specified pipeline within a week, add filters, no error is reported, but the returned result is all records in the time period

filter_parameters = RunFilterParameters(
        last_updated_after=last_sunday,
        last_updated_before=this_monday,
        filters=RunQueryFilter(operand="PipelineName", operator="Equals", values="D365")
    )
    credential = AzureCliCredential()
    datafactory_client = DataFactoryManagementClient(
        credential=credential,
        subscription_id=conf[azure_env]['subscription_id'],
        base_url=CLOUD.endpoints.resource_manager,
        credential_scopes=[CLOUD.endpoints.resource_manager + "/.default"]
    )
    query_data = datafactory_client.pipeline_runs.query_by_factory(
        resource_group_name=conf[azure_env]['resource_group_name'],
        factory_name=conf[azure_env]['factory_name'],
        filter_parameters=filter_parameters
    )

image

mccoyp commented 1 year ago

Hi @ChronosRoot, thank you for opening an issue! I'll tag some folks who can help and we'll get back to you as soon as possible.

ghost commented 1 year ago

Thank you for your feedback. This has been routed to the support team for assistance.

SaurabhSharma-MSFT commented 1 year ago

@ChronosRoot Thanks for your feedback! We will investigate and update as appropriate.

SaurabhSharma-MSFT commented 1 year ago

@ChronosSong I am seeing the same behavior and looking into it. I will update you back on this.

Wzb123456789 commented 1 year ago

Hi @ChronosSong thanks for your feedback!

I found that there is some problem with the parameter format you fill in the function since filters in RunFilterParameters shall be list, I suggest you try the following ways to solve your problem,like

filter_parameters = RunFilterParameters(
        last_updated_after=last_sunday,
        last_updated_before=this_monday,
        filters=[RunQueryFilter(operand="PipelineName", operator="Equals", values=["D365"])]
    )
query_data = datafactory_client.pipeline_runs.query_by_factory(
    resource_group_name=conf[azure_env]['resource_group_name'],
    factory_name=conf[azure_env]['factory_name'],
    filter_parameters=filter_parameters 
)

image

ghost commented 1 year ago

Hi @ChronosSong. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

SaurabhSharma-MSFT commented 1 year ago

@Wzb123456789 Thanks for looking into this but I have tried your code, but it is throwing error. image

Wzb123456789 commented 1 year ago

@SaurabhSharma-MSFT

The above solution is a little wrong, it has been corrected, please try again.

ChronosSong commented 1 year ago

I found that some parameters were lost during the serialization and conversion of json by filter_parameters. Code azure/mgmt/datafactory/operations/_pipeline_runs_operations.py Line 283 _json = self._serialize.body(filter_parameters, "RunFilterParameters") When i run the code. filter_parameters {'additional_properties': {}, 'continuation_token': None, 'last_updated_after': datetime.datetime(2022, 10, 17, 0, 0, tzinfo=zoneinfo.ZoneInfo(key='Asia/Shanghai')), 'last_updated_before': datetime.datetime(2022, 10, 24, 0, 0, tzinfo=zoneinfo.ZoneInfo(key='Asia/Shanghai')), 'filters': <azure.mgmt.datafactory.models._models_py3.RunQueryFilter object at 0x1031aec70>, 'order_by': None} But the returned json only has time left. _json {'lastUpdatedAfter': '2022-10-16T16:00:00.000Z', 'lastUpdatedBefore': '2022-10-23T16:00:00.000Z'} I'm not very good at python serialization and am confused about it

SaurabhSharma-MSFT commented 1 year ago

Thanks @Wzb123456789 but I am still seeing error with the new code. image

msyyc commented 1 year ago

Hi @ChronosSong The serialization error shall be caused by wrong input of values: image I fix it and please try https://github.com/Azure/azure-sdk-for-python/issues/26558#issuecomment-1288455249 again.

SaurabhSharma-MSFT commented 1 year ago

Thanks @msyyc. It works for me now.

@ChronosSong Waiting for your confirmation.

ghost commented 1 year ago

Hi @ChronosSong. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

ChronosSong commented 1 year ago

@mccoyp Thanks for the guidance, it worked