You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2020/03/25 01:26:12 UTC

[GitHub] [incubator-superset] dandanhub opened a new pull request #9376: Add CUSTOM_TEMPLATE_PROCESSOR config

dandanhub opened a new pull request #9376: Add CUSTOM_TEMPLATE_PROCESSOR config
URL: https://github.com/apache/incubator-superset/pull/9376
 
 
   ### CATEGORY
   
   Choose one
   
   - [ ] Bug Fix
   - [x] Enhancement (new features, refinement)
   - [ ] Refactor
   - [ ] Add tests
   - [ ] Build / Development Environment
   - [ ] Documentation
   
   ### SUMMARY
   Superset by default only supports templating using the Jinja templating language which allows for using macros in your SQL code.
   
   The PR is to introduce CUSTOM_TEMPLATE_PROCESSOR config to allow customizing macros template processors for various database engine. A good example of usage is to support processor that treats $MACRO as macro, as opposed to {{ JINJIA_TEMPLATE }}. 
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TEST PLAN
   1. Added unit test
   2. Did integrate test on local environment
   3. Did manual test on local Superset environment
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Changes UI
   - [ ] Requires DB Migration.
   - [ ] Confirm DB Migration upgrade and downgrade tested.
   - [x] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   ### REVIEWERS
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [incubator-superset] dandanhub commented on issue #9376: Add CUSTOM_TEMPLATE_PROCESSOR config

Posted by GitBox <gi...@apache.org>.
dandanhub commented on issue #9376: Add CUSTOM_TEMPLATE_PROCESSOR config
URL: https://github.com/apache/incubator-superset/pull/9376#issuecomment-608251488
 
 
   @dpgaspar @craig-rueda would you please have another review on the PR? Thanks!

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [incubator-superset] dpgaspar merged pull request #9376: Add CUSTOM_TEMPLATE_PROCESSOR config

Posted by GitBox <gi...@apache.org>.
dpgaspar merged pull request #9376: Add CUSTOM_TEMPLATE_PROCESSOR config
URL: https://github.com/apache/incubator-superset/pull/9376
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [incubator-superset] craig-rueda commented on a change in pull request #9376: Add CUSTOM_TEMPLATE_PROCESSOR config

Posted by GitBox <gi...@apache.org>.
craig-rueda commented on a change in pull request #9376: Add CUSTOM_TEMPLATE_PROCESSOR config
URL: https://github.com/apache/incubator-superset/pull/9376#discussion_r398655398
 
 

 ##########
 File path: tests/superset_test_config.py
 ##########
 @@ -56,3 +61,44 @@ class CeleryConfig(object):
 
 
 CELERY_CONFIG = CeleryConfig
+
+
+def DATE(
+    ts: datetime, day_offset: SupportsInt = 0, hour_offset: SupportsInt = 0
+) -> str:
+    """Current day as a string"""
+    day_offset, hour_offset = int(day_offset), int(hour_offset)
+    offset_day = (ts + timedelta(days=day_offset, hours=hour_offset)).date()
+    return str(offset_day)
+
+
+class CustomPrestoTemplateProcessor(PrestoTemplateProcessor):
 
 Review comment:
   Pull this out into its own file / test?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [incubator-superset] dandanhub commented on a change in pull request #9376: Add CUSTOM_TEMPLATE_PROCESSOR config

Posted by GitBox <gi...@apache.org>.
dandanhub commented on a change in pull request #9376: Add CUSTOM_TEMPLATE_PROCESSOR config
URL: https://github.com/apache/incubator-superset/pull/9376#discussion_r403174740
 
 

 ##########
 File path: superset/config.py
 ##########
 @@ -585,6 +588,13 @@ class CeleryConfig:  # pylint: disable=too-few-public-methods
 # dictionary.
 JINJA_CONTEXT_ADDONS: Dict[str, Callable] = {}
 
+# A dictionary of macro template processors that gets merged into global
+# template processors. The existing template processors get updated with this
+# dictionary, which means the existing keys get overwritten by the content of this
+# dictionary. The customized addons don't necessarily need to use jinjia templating
+# language. This allows you to define custom logic to process macro template.
+CUSTOM_TEMPLATE_PROCESSOR = {}  # type: Dict[str, BaseTemplateProcessor]
 
 Review comment:
   Sure!

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [incubator-superset] dandanhub commented on issue #9376: Add CUSTOM_TEMPLATE_PROCESSOR config

Posted by GitBox <gi...@apache.org>.
dandanhub commented on issue #9376: Add CUSTOM_TEMPLATE_PROCESSOR config
URL: https://github.com/apache/incubator-superset/pull/9376#issuecomment-609530334
 
 
   Thanks @dpgaspar resolved the conflict. If you can help merge the PR to upstream, that would be much appreciated. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [incubator-superset] dpgaspar commented on a change in pull request #9376: Add CUSTOM_TEMPLATE_PROCESSOR config

Posted by GitBox <gi...@apache.org>.
dpgaspar commented on a change in pull request #9376: Add CUSTOM_TEMPLATE_PROCESSOR config
URL: https://github.com/apache/incubator-superset/pull/9376#discussion_r398311680
 
 

 ##########
 File path: superset/config.py
 ##########
 @@ -585,6 +588,59 @@ class CeleryConfig:  # pylint: disable=too-few-public-methods
 # dictionary.
 JINJA_CONTEXT_ADDONS: Dict[str, Callable] = {}
 
+# A dictionary of macro template processors that gets merged into global
+# jinja template processors. The existing template processors get updated with this
+# dictionary, which means the existing keys get overwritten by the content of this
+# dictionary. The customized addons don't necessarily need to use jinjia templating
+# language. This allows you to define custom logic to process macro template.
+#
+# The example below configures a custom presto template processor which implements
+# its own logic of processing macro template with regex parsing. It uses $ style
+# macro instead of Jinja's {{ }} style.
+# By configuring it with CUSTOM_TEMPLATE_PROCESSOR, sql template on presto database
+# is processed by the custom one rather than the default one.
+#
+# def DATE(
+#     ts: datetime, day_offset: SupportsInt = 0, hour_offset: SupportsInt = 0
+# ) -> str:
+#     """Current day as a string"""
+#     day_offset, hour_offset = int(day_offset), int(hour_offset)
+#     offset_day = (ts + timedelta(days=day_offset, hours=hour_offset)).date()
+#     return str(offset_day)
+#
+# class CustomPrestoTemplateProcessor(PrestoTemplateProcessor):
 
 Review comment:
   Maybe move this example to the docs, and just leave a nice short description on the config

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [incubator-superset] craig-rueda commented on a change in pull request #9376: Add CUSTOM_TEMPLATE_PROCESSOR config

Posted by GitBox <gi...@apache.org>.
craig-rueda commented on a change in pull request #9376: Add CUSTOM_TEMPLATE_PROCESSOR config
URL: https://github.com/apache/incubator-superset/pull/9376#discussion_r398654288
 
 

 ##########
 File path: superset/config.py
 ##########
 @@ -585,6 +588,59 @@ class CeleryConfig:  # pylint: disable=too-few-public-methods
 # dictionary.
 JINJA_CONTEXT_ADDONS: Dict[str, Callable] = {}
 
+# A dictionary of macro template processors that gets merged into global
+# jinja template processors. The existing template processors get updated with this
+# dictionary, which means the existing keys get overwritten by the content of this
+# dictionary. The customized addons don't necessarily need to use jinjia templating
+# language. This allows you to define custom logic to process macro template.
+#
+# The example below configures a custom presto template processor which implements
+# its own logic of processing macro template with regex parsing. It uses $ style
+# macro instead of Jinja's {{ }} style.
+# By configuring it with CUSTOM_TEMPLATE_PROCESSOR, sql template on presto database
+# is processed by the custom one rather than the default one.
+#
+# def DATE(
+#     ts: datetime, day_offset: SupportsInt = 0, hour_offset: SupportsInt = 0
+# ) -> str:
+#     """Current day as a string"""
+#     day_offset, hour_offset = int(day_offset), int(hour_offset)
+#     offset_day = (ts + timedelta(days=day_offset, hours=hour_offset)).date()
+#     return str(offset_day)
+#
+# class CustomPrestoTemplateProcessor(PrestoTemplateProcessor):
 
 Review comment:
   +1 - This should be somewhere else -- could even just reference your test processor

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [incubator-superset] codecov-io commented on issue #9376: Add CUSTOM_TEMPLATE_PROCESSOR config

Posted by GitBox <gi...@apache.org>.
codecov-io commented on issue #9376: Add CUSTOM_TEMPLATE_PROCESSOR config
URL: https://github.com/apache/incubator-superset/pull/9376#issuecomment-609529938
 
 
   # [Codecov](https://codecov.io/gh/apache/incubator-superset/pull/9376?src=pr&el=h1) Report
   > Merging [#9376](https://codecov.io/gh/apache/incubator-superset/pull/9376?src=pr&el=desc) into [master](https://codecov.io/gh/apache/incubator-superset/commit/801e2f1777a9b213dc35bb6cc190816b9dcabf36&el=desc) will **not change** coverage by `%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-superset/pull/9376/graphs/tree.svg?width=650&height=150&src=pr&token=KsB0fHcx6l)](https://codecov.io/gh/apache/incubator-superset/pull/9376?src=pr&el=tree)
   
   ```diff
   @@           Coverage Diff           @@
   ##           master    #9376   +/-   ##
   =======================================
     Coverage   59.01%   59.01%           
   =======================================
     Files         383      383           
     Lines       12191    12191           
     Branches     3014     3014           
   =======================================
     Hits         7194     7194           
     Misses       4813     4813           
     Partials      184      184           
   ```
   
   
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-superset/pull/9376?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-superset/pull/9376?src=pr&el=footer). Last update [801e2f1...8e63194](https://codecov.io/gh/apache/incubator-superset/pull/9376?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [incubator-superset] dandanhub commented on a change in pull request #9376: Add CUSTOM_TEMPLATE_PROCESSOR config

Posted by GitBox <gi...@apache.org>.
dandanhub commented on a change in pull request #9376: Add CUSTOM_TEMPLATE_PROCESSOR config
URL: https://github.com/apache/incubator-superset/pull/9376#discussion_r399060256
 
 

 ##########
 File path: tests/core_tests.py
 ##########
 @@ -668,6 +668,80 @@ def test_templated_sql_json(self):
         data = self.run_sql(sql, "fdaklj3ws")
         self.assertEqual(data["data"][0]["test"], "2017-01-01T00:00:00")
 
+    @mock.patch("tests.superset_test_config.datetime")
+    def test_custom_process_template(self, mock_dt) -> None:
+        """Test macro defined in custom template processor works."""
+        mock_dt.utcnow = mock.Mock(return_value=datetime.datetime(1970, 1, 1))
+        db = mock.Mock()
+        db.backend = "presto"
+        tp = jinja_context.get_template_processor(database=db)
+
+        sql = "SELECT '$DATE()'"
+        rendered = tp.process_template(sql)
+        self.assertEqual("SELECT '{}'".format("1970-01-01"), rendered)
+
 
 Review comment:
   Sure.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [incubator-superset] dandanhub commented on issue #9376: Add CUSTOM_TEMPLATE_PROCESSOR config

Posted by GitBox <gi...@apache.org>.
dandanhub commented on issue #9376: Add CUSTOM_TEMPLATE_PROCESSOR config
URL: https://github.com/apache/incubator-superset/pull/9376#issuecomment-608567371
 
 
   @craig-rueda I addressed the comment. Would you mind having another review?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [incubator-superset] dpgaspar commented on issue #9376: Add CUSTOM_TEMPLATE_PROCESSOR config

Posted by GitBox <gi...@apache.org>.
dpgaspar commented on issue #9376: Add CUSTOM_TEMPLATE_PROCESSOR config
URL: https://github.com/apache/incubator-superset/pull/9376#issuecomment-609450035
 
 
   Looks good, but some conflicts need to be solved

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [incubator-superset] dpgaspar commented on a change in pull request #9376: Add CUSTOM_TEMPLATE_PROCESSOR config

Posted by GitBox <gi...@apache.org>.
dpgaspar commented on a change in pull request #9376: Add CUSTOM_TEMPLATE_PROCESSOR config
URL: https://github.com/apache/incubator-superset/pull/9376#discussion_r398314274
 
 

 ##########
 File path: tests/core_tests.py
 ##########
 @@ -668,6 +668,80 @@ def test_templated_sql_json(self):
         data = self.run_sql(sql, "fdaklj3ws")
         self.assertEqual(data["data"][0]["test"], "2017-01-01T00:00:00")
 
+    @mock.patch("tests.superset_test_config.datetime")
+    def test_custom_process_template(self, mock_dt) -> None:
+        """Test macro defined in custom template processor works."""
+        mock_dt.utcnow = mock.Mock(return_value=datetime.datetime(1970, 1, 1))
+        db = mock.Mock()
+        db.backend = "presto"
+        tp = jinja_context.get_template_processor(database=db)
+
+        sql = "SELECT '$DATE()'"
+        rendered = tp.process_template(sql)
+        self.assertEqual("SELECT '{}'".format("1970-01-01"), rendered)
+
 
 Review comment:
   It would be nice to have a test with a different backend and check that the macro is ignored

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [incubator-superset] dandanhub commented on a change in pull request #9376: Add CUSTOM_TEMPLATE_PROCESSOR config

Posted by GitBox <gi...@apache.org>.
dandanhub commented on a change in pull request #9376: Add CUSTOM_TEMPLATE_PROCESSOR config
URL: https://github.com/apache/incubator-superset/pull/9376#discussion_r399060006
 
 

 ##########
 File path: superset/config.py
 ##########
 @@ -585,6 +588,59 @@ class CeleryConfig:  # pylint: disable=too-few-public-methods
 # dictionary.
 JINJA_CONTEXT_ADDONS: Dict[str, Callable] = {}
 
+# A dictionary of macro template processors that gets merged into global
+# jinja template processors. The existing template processors get updated with this
+# dictionary, which means the existing keys get overwritten by the content of this
+# dictionary. The customized addons don't necessarily need to use jinjia templating
+# language. This allows you to define custom logic to process macro template.
+#
+# The example below configures a custom presto template processor which implements
+# its own logic of processing macro template with regex parsing. It uses $ style
+# macro instead of Jinja's {{ }} style.
+# By configuring it with CUSTOM_TEMPLATE_PROCESSOR, sql template on presto database
+# is processed by the custom one rather than the default one.
+#
+# def DATE(
+#     ts: datetime, day_offset: SupportsInt = 0, hour_offset: SupportsInt = 0
+# ) -> str:
+#     """Current day as a string"""
+#     day_offset, hour_offset = int(day_offset), int(hour_offset)
+#     offset_day = (ts + timedelta(days=day_offset, hours=hour_offset)).date()
+#     return str(offset_day)
+#
+# class CustomPrestoTemplateProcessor(PrestoTemplateProcessor):
 
 Review comment:
   Ack.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [incubator-superset] dandanhub commented on a change in pull request #9376: Add CUSTOM_TEMPLATE_PROCESSOR config

Posted by GitBox <gi...@apache.org>.
dandanhub commented on a change in pull request #9376: Add CUSTOM_TEMPLATE_PROCESSOR config
URL: https://github.com/apache/incubator-superset/pull/9376#discussion_r399060501
 
 

 ##########
 File path: tests/superset_test_config.py
 ##########
 @@ -56,3 +61,44 @@ class CeleryConfig(object):
 
 
 CELERY_CONFIG = CeleryConfig
+
+
+def DATE(
+    ts: datetime, day_offset: SupportsInt = 0, hour_offset: SupportsInt = 0
+) -> str:
+    """Current day as a string"""
+    day_offset, hour_offset = int(day_offset), int(hour_offset)
+    offset_day = (ts + timedelta(days=day_offset, hours=hour_offset)).date()
+    return str(offset_day)
+
+
+class CustomPrestoTemplateProcessor(PrestoTemplateProcessor):
 
 Review comment:
   Sure.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [incubator-superset] craig-rueda commented on a change in pull request #9376: Add CUSTOM_TEMPLATE_PROCESSOR config

Posted by GitBox <gi...@apache.org>.
craig-rueda commented on a change in pull request #9376: Add CUSTOM_TEMPLATE_PROCESSOR config
URL: https://github.com/apache/incubator-superset/pull/9376#discussion_r403081268
 
 

 ##########
 File path: superset/config.py
 ##########
 @@ -585,6 +588,13 @@ class CeleryConfig:  # pylint: disable=too-few-public-methods
 # dictionary.
 JINJA_CONTEXT_ADDONS: Dict[str, Callable] = {}
 
+# A dictionary of macro template processors that gets merged into global
+# template processors. The existing template processors get updated with this
+# dictionary, which means the existing keys get overwritten by the content of this
+# dictionary. The customized addons don't necessarily need to use jinjia templating
+# language. This allows you to define custom logic to process macro template.
+CUSTOM_TEMPLATE_PROCESSOR = {}  # type: Dict[str, BaseTemplateProcessor]
 
 Review comment:
   Nit: naming here -- `CUSTOM_TEMPLATE_PROCESSOR` should be something like `CUSTOM_TEMPLATE_PROCESSOR_MAP` or even just `CUSTOM_TEMPLATE_PROCESSORS`, as there can potentially be several processors configured via this config property.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [incubator-superset] dpgaspar commented on a change in pull request #9376: Add CUSTOM_TEMPLATE_PROCESSOR config

Posted by GitBox <gi...@apache.org>.
dpgaspar commented on a change in pull request #9376: Add CUSTOM_TEMPLATE_PROCESSOR config
URL: https://github.com/apache/incubator-superset/pull/9376#discussion_r398311460
 
 

 ##########
 File path: superset/config.py
 ##########
 @@ -585,6 +588,59 @@ class CeleryConfig:  # pylint: disable=too-few-public-methods
 # dictionary.
 JINJA_CONTEXT_ADDONS: Dict[str, Callable] = {}
 
+# A dictionary of macro template processors that gets merged into global
+# jinja template processors. The existing template processors get updated with this
+# dictionary, which means the existing keys get overwritten by the content of this
+# dictionary. The customized addons don't necessarily need to use jinjia templating
+# language. This allows you to define custom logic to process macro template.
+#
+# The example below configures a custom presto template processor which implements
+# its own logic of processing macro template with regex parsing. It uses $ style
+# macro instead of Jinja's {{ }} style.
+# By configuring it with CUSTOM_TEMPLATE_PROCESSOR, sql template on presto database
 
 Review comment:
   Why the need to completely override jinja's template processor? JINJA_CONTEXT_ADDONS should be powerful enough   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [incubator-superset] dandanhub commented on a change in pull request #9376: Add CUSTOM_TEMPLATE_PROCESSOR config

Posted by GitBox <gi...@apache.org>.
dandanhub commented on a change in pull request #9376: Add CUSTOM_TEMPLATE_PROCESSOR config
URL: https://github.com/apache/incubator-superset/pull/9376#discussion_r399059856
 
 

 ##########
 File path: superset/config.py
 ##########
 @@ -585,6 +588,59 @@ class CeleryConfig:  # pylint: disable=too-few-public-methods
 # dictionary.
 JINJA_CONTEXT_ADDONS: Dict[str, Callable] = {}
 
+# A dictionary of macro template processors that gets merged into global
+# jinja template processors. The existing template processors get updated with this
+# dictionary, which means the existing keys get overwritten by the content of this
+# dictionary. The customized addons don't necessarily need to use jinjia templating
+# language. This allows you to define custom logic to process macro template.
+#
+# The example below configures a custom presto template processor which implements
+# its own logic of processing macro template with regex parsing. It uses $ style
+# macro instead of Jinja's {{ }} style.
+# By configuring it with CUSTOM_TEMPLATE_PROCESSOR, sql template on presto database
 
 Review comment:
   `JINJA_CONTEXT_ADDONS` is to add customized macro function to plug into jinja templating, but what the new config does is to allow you to customize the way of evaluating template, i.e. parse `$DATE(0)` (dollar-sign) as a macro as opposed to `{{ DATE(0)}}` (jinja curly-braces).

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org