Title: Cannot form the union of more than two tables · Issue #926 · datajoint/datajoint-python · GitHub
Open Graph Title: Cannot form the union of more than two tables · Issue #926 · datajoint/datajoint-python
X Title: Cannot form the union of more than two tables · Issue #926 · datajoint/datajoint-python
Description: Bug Report Description I have a situation where I need to take the union over multiple tables (restriction or other methods will not work in this case). Taking the union over more than two tables throws an error. Reproducibility Include:...
Open Graph Description: Bug Report Description I have a situation where I need to take the union over multiple tables (restriction or other methods will not work in this case). Taking the union over more than two tables t...
X Description: Bug Report Description I have a situation where I need to take the union over multiple tables (restriction or other methods will not work in this case). Taking the union over more than two tables t...
Opengraph URL: https://github.com/datajoint/datajoint-python/issues/926
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cannot form the union of more than two tables","articleBody":"## Bug Report\r\n\r\n### Description\r\nI have a situation where I need to take the union over multiple tables (restriction or other methods will not work in this case). Taking the union over more than two tables throws an error.\r\n\r\n### Reproducibility\r\nInclude:\r\n- OS (MACOS)\r\n- Python Version 3.8.8\r\n- MySQL Deployment Strategy (remote)\r\n- DataJoint Version 0.13.2\r\n\r\nThis is a trivial example that seems to reproduce the issue:\r\n```python\r\n@schema\r\nclass Params(dj.Lookup):\r\n definition = \"\"\"\r\n params_id: tinyint unsigned\r\n \"\"\"\r\n\r\nParams.insert([[x] for x in range(3)])\r\n\r\nparams = [Params \u0026 {'params_id': x} for x in range(3)]\r\n\r\nparams[0] + params[1] + params[2]\r\n```\r\n\r\nError stack:\r\n```console\r\n---------------------------------------------------------------------------\r\nTypeError Traceback (most recent call last)\r\n~/anaconda3/envs/neural-data-kit/lib/python3.8/site-packages/IPython/core/formatters.py in __call__(self, obj)\r\n 700 type_pprinters=self.type_printers,\r\n 701 deferred_pprinters=self.deferred_printers)\r\n--\u003e 702 printer.pretty(obj)\r\n 703 printer.flush()\r\n 704 return stream.getvalue()\r\n\r\n~/anaconda3/envs/neural-data-kit/lib/python3.8/site-packages/IPython/lib/pretty.py in pretty(self, obj)\r\n 392 if cls is not object \\\r\n 393 and callable(cls.__dict__.get('__repr__')):\r\n--\u003e 394 return _repr_pprint(obj, self, cycle)\r\n 395 \r\n 396 return _default_pprint(obj, self, cycle)\r\n\r\n~/anaconda3/envs/neural-data-kit/lib/python3.8/site-packages/IPython/lib/pretty.py in _repr_pprint(obj, p, cycle)\r\n 698 \"\"\"A pprint that just redirects to the normal repr function.\"\"\"\r\n 699 # Find newlines and replace them with p.break_()\r\n--\u003e 700 output = repr(obj)\r\n 701 lines = output.splitlines()\r\n 702 with p.group():\r\n\r\n~/anaconda3/envs/neural-data-kit/lib/python3.8/site-packages/datajoint/expression.py in __repr__(self)\r\n 527 :rtype: str\r\n 528 \"\"\"\r\n--\u003e 529 return super().__repr__() if config['loglevel'].lower() == 'debug' else self.preview()\r\n 530 \r\n 531 def preview(self, limit=None, width=None):\r\n\r\n~/anaconda3/envs/neural-data-kit/lib/python3.8/site-packages/datajoint/expression.py in preview(self, limit, width)\r\n 531 def preview(self, limit=None, width=None):\r\n 532 \"\"\" :return: a string of preview of the contents of the query. \"\"\"\r\n--\u003e 533 return preview(self, limit, width)\r\n 534 \r\n 535 def _repr_html_(self):\r\n\r\n~/anaconda3/envs/neural-data-kit/lib/python3.8/site-packages/datajoint/preview.py in preview(query_expression, limit, width)\r\n 11 if width is None:\r\n 12 width = config['display.width']\r\n---\u003e 13 tuples = rel.fetch(limit=limit + 1, format=\"array\")\r\n 14 has_more = len(tuples) \u003e limit\r\n 15 tuples = tuples[:limit]\r\n\r\n~/anaconda3/envs/neural-data-kit/lib/python3.8/site-packages/datajoint/fetch.py in __call__(self, offset, limit, order_by, format, as_dict, squeeze, download_path, *attrs)\r\n 190 ret = return_values[0] if len(attrs) == 1 else return_values\r\n 191 else: # fetch all attributes as a numpy.record_array or pandas.DataFrame\r\n--\u003e 192 cur = self._expression.cursor(\r\n 193 as_dict=as_dict, limit=limit, offset=offset, order_by=order_by)\r\n 194 heading = self._expression.heading\r\n\r\n~/anaconda3/envs/neural-data-kit/lib/python3.8/site-packages/datajoint/expression.py in cursor(self, offset, limit, order_by, as_dict)\r\n 511 if offset and limit is None:\r\n 512 raise DataJointError('limit is required when offset is set')\r\n--\u003e 513 sql = self.make_sql()\r\n 514 if order_by is not None:\r\n 515 sql += ' ORDER BY ' + ', '.join(order_by)\r\n\r\n~/anaconda3/envs/neural-data-kit/lib/python3.8/site-packages/datajoint/expression.py in make_sql(self, fields)\r\n 111 distinct=\"DISTINCT \" if distinct else \"\",\r\n 112 fields=self.heading.as_sql(fields or self.heading.names),\r\n--\u003e 113 from_=self.from_clause(), where=self.where_clause())\r\n 114 \r\n 115 # --------- query operators -----------\r\n\r\n~/anaconda3/envs/neural-data-kit/lib/python3.8/site-packages/datajoint/expression.py in from_clause(self)\r\n 91 self._subquery_alias_count) if isinstance(src, QueryExpression)\r\n 92 else src for src in self.support)\r\n---\u003e 93 clause = next(support)\r\n 94 for s, left in zip(support, self._left):\r\n 95 clause += ' NATURAL{left} JOIN {clause}'.format(\r\n\r\n~/anaconda3/envs/neural-data-kit/lib/python3.8/site-packages/datajoint/expression.py in (.0)\r\n 88 \r\n 89 def from_clause(self):\r\n---\u003e 90 support = ('(' + src.make_sql() + ') as `$%x`' % next(\r\n 91 self._subquery_alias_count) if isinstance(src, QueryExpression)\r\n 92 else src for src in self.support)\r\n\r\n~/anaconda3/envs/neural-data-kit/lib/python3.8/site-packages/datajoint/expression.py in make_sql(self)\r\n 627 fields = arg1.primary_key\r\n 628 return \"({sql1}) UNION ({sql2})\".format(\r\n--\u003e 629 sql1=arg1.make_sql(fields),\r\n 630 sql2=arg2.make_sql(fields))\r\n 631 # with secondary attributes, use union of left join with antijoin\r\n\r\nTypeError: make_sql() takes 1 positional argument but 2 were given\r\n```\r\n\r\n### Expected Behavior\r\nForming the union over two elements of `params` works as expected with the same setup as described above.\r\n\r\nNote: taking the union over more than two tables **does** work for python version 3.8.2 and datajoint version 0.12.6.\r\n","author":{"url":"https://github.com/najjajm","@type":"Person","name":"najjajm"},"datePublished":"2021-05-26T17:58:57.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/926/datajoint-python/issues/926"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6deeca04-94e2-0221-6d20-da7c5b7bcb69 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 827A:C4224:16C406:1E7332:6A4D94D3 |
| html-safe-nonce | dd77881fbf20c5a76902188458c56a0e84b13df97e5bdd83b8c1763c6b40ada2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MjdBOkM0MjI0OjE2QzQwNjoxRTczMzI6NkE0RDk0RDMiLCJ2aXNpdG9yX2lkIjoiNDkxMDczMjYwMTQ4MjY0NjczOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 00e01dbb7faa532b6252b2ad0f8c54476a130f345a4197a1784fb017de35e2a0 |
| hovercard-subject-tag | issue:902754307 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/datajoint/datajoint-python/926/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7565daeb722f4f75a8f5d10d0c6ec136f517f95979bd91812a0e02ef57fa1104/datajoint/datajoint-python/issues/926 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7565daeb722f4f75a8f5d10d0c6ec136f517f95979bd91812a0e02ef57fa1104/datajoint/datajoint-python/issues/926 |
| og:image:alt | Bug Report Description I have a situation where I need to take the union over multiple tables (restriction or other methods will not work in this case). Taking the union over more than two tables t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | najjajm |
| hostname | github.com |
| expected-hostname | github.com |
| None | 06b8a6144231bf3a234f1c2e9993861e07ce98a905912b114aa386c2d7e84b33 |
| turbo-cache-control | no-preview |
| go-import | github.com/datajoint/datajoint-python git https://github.com/datajoint/datajoint-python.git |
| octolytics-dimension-user_id | 2375501 |
| octolytics-dimension-user_login | datajoint |
| octolytics-dimension-repository_id | 5866704 |
| octolytics-dimension-repository_nwo | datajoint/datajoint-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 5866704 |
| octolytics-dimension-repository_network_root_nwo | datajoint/datajoint-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 74e2a9c78f1e38588de4f25885878349d721eedf |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width