Skip to content

Commit

Permalink
add support for custom file ending (#5845)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenyuLInx authored Sep 19, 2022
1 parent 3680b6a commit 13a5957
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
23 changes: 16 additions & 7 deletions core/dbt/contracts/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,25 +114,34 @@ def from_contents(cls, contents: str, name="sha256") -> "FileHash":

@dataclass
class RemoteFile(dbtClassMixin):
def __init__(self, language) -> None:
if language == "sql":
self.path_end = ".sql"
elif language == "python":
self.path_end = ".py"
else:
raise RuntimeError(f"Invalid language for remote File {language}")
self.path = f"from remote system{self.path_end}"

@property
def searched_path(self) -> str:
return "from remote system"
return self.path

@property
def relative_path(self) -> str:
return "from remote system"
return self.path

@property
def absolute_path(self) -> str:
return "from remote system"
return self.path

@property
def original_file_path(self):
return "from remote system"
return self.path

@property
def modification_time(self):
return "from remote system"
return self.path


@dataclass
Expand Down Expand Up @@ -202,9 +211,9 @@ def add_node(self, value):
# TODO: do this a different way. This remote file kludge isn't going
# to work long term
@classmethod
def remote(cls, contents: str, project_name: str) -> "SourceFile":
def remote(cls, contents: str, project_name: str, language: str) -> "SourceFile":
self = cls(
path=RemoteFile(),
path=RemoteFile(language),
checksum=FileHash.from_contents(contents),
project_name=project_name,
contents=contents,
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/parser/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def get_compiled_path(block: FileBlock):
return os.path.join("sql", block.name)

def parse_remote(self, sql: str, name: str) -> ParsedSqlNode:
source_file = SourceFile.remote(sql, self.project.project_name)
source_file = SourceFile.remote(sql, self.project.project_name, "sql")
contents = SqlBlock(block_name=name, file=source_file)
return self.parse_node(contents)

Expand Down

0 comments on commit 13a5957

Please sign in to comment.