MCPcopy
hub / github.com/pathwaycom/pathway / handler

Function handler

python/pathway/internals/arg_handlers.py:73–175  ·  view source on GitHub ↗
(self, other, *on, **kwargs)

Source from the content-addressed store, hash-verified

71
72def join_kwargs_handler(*, allow_how: bool, allow_id: bool):
73 def handler(self, other, *on, **kwargs):
74 processed_kwargs = {}
75 if "how" in kwargs:
76 how = kwargs.pop("how")
77 processed_kwargs["how"] = how
78 if not allow_how:
79 raise ValueError(
80 "Received `how` argument but was not expecting any.\n"
81 + "Consider using a generic join method that handles `how` "
82 + "to decide on a type of a join to be used."
83 )
84 elif isinstance(how, JoinMode):
85 pass
86 elif isinstance(how, str):
87 raise ValueError(
88 "Received `how` argument of join that is a string.\n"
89 + "You probably want to use one of "
90 + "JoinMode.INNER, JoinMode.LEFT, JoinMode.RIGHT or JoinMode.OUTER values."
91 )
92 else:
93 raise ValueError(
94 "How argument of join should be one of "
95 + "JoinMode.INNER, JoinMode.LEFT, JoinMode.RIGHT or JoinMode.OUTER values."
96 )
97
98 if "id" in kwargs:
99 id = kwargs.pop("id")
100 processed_kwargs["id"] = id
101 if not allow_id:
102 raise ValueError(
103 "Received `id` argument but was not expecting any.\n"
104 + "Not every join type supports `id` argument."
105 )
106 elif id is None:
107 pass
108 elif isinstance(id, str):
109 raise ValueError(
110 "Received `id` argument of join that is a string.\n"
111 + f"Did you mean <table>.{id}"
112 + f" instead of {repr(id)}?"
113 )
114 elif not isinstance(id, expr.ColumnReference):
115 raise ValueError(
116 "The id argument of a join has to be a ColumnReference."
117 )
118
119 if "defaults" in kwargs:
120 processed_kwargs["defaults"] = kwargs.pop("defaults")
121
122 if "left_instance" in kwargs and "right_instance" in kwargs:
123 processed_kwargs["left_instance"] = kwargs.pop("left_instance")
124 processed_kwargs["right_instance"] = kwargs.pop("right_instance")
125 elif "left_instance" in kwargs or "right_instance" in kwargs:
126 raise ValueError(
127 "`left_instance` and `right_instance` arguments to join "
128 + "should always be provided simultaneously"
129 )
130

Callers 6

innerFunction · 0.70
serveMethod · 0.50
wrapperMethod · 0.50
serveMethod · 0.50
_runFunction · 0.50
eval_method_callMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected