Skip to content

Commit 47d8196

Browse files
remove code repetition
1 parent 4dd1102 commit 47d8196

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

elasticsearch/esql/esql.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,17 +1141,14 @@ def _render_internal(self) -> str:
11411141
if self._named_query:
11421142
column = list(self._named_query.keys())[0]
11431143
query = list(self._named_query.values())[0]
1144-
return (
1145-
f"RERANK {self._format_id(column)} = {json.dumps(query)} "
1146-
f"ON {', '.join([self._format_id(field) for field in self._fields])} "
1147-
f"WITH {json.dumps(with_)}"
1148-
)
1144+
query = f"{self._format_id(column)} = {json.dumps(query)}"
11491145
else:
1150-
return (
1151-
f"RERANK {json.dumps(self._query[0])} "
1152-
f"ON {', '.join([self._format_id(field) for field in self._fields])} "
1153-
f"WITH {json.dumps(with_)}"
1154-
)
1146+
query = json.dumps(self._query[0])
1147+
return (
1148+
f"RERANK {query} "
1149+
f"ON {', '.join([self._format_id(field) for field in self._fields])} "
1150+
f"WITH {json.dumps(with_)}"
1151+
)
11551152

11561153

11571154
class Sample(ESQLBase):

0 commit comments

Comments
 (0)