mz-sql-navigation

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Navigating Materialize SQL

导航Materialize SQL

The
mz-deploy
language server answers questions about an mz-deploy project's object graph. Use the LSP tool for these instead of text search — grep finds strings that look like an object name, the language server finds the object.
mz-deploy
语言服务可解答关于mz-deploy项目对象图的问题。请使用LSP工具完成这些操作,而非文本搜索——grep只能查找类似对象名称的字符串,而语言服务能精准定位到对象本身。

What to use it for

适用场景

  • Go to definition — resolve where a referenced view, table, source, or index is defined, including across schemas.
  • Hover — inspect an object's columns and their types without opening its definition.
  • Document symbols — list the objects a single
    .sql
    file defines.
  • Workspace symbols — locate an object by name when you don't know its file.
Before changing an object, use these to find what depends on it. In Materialize a view's definition constrains everything downstream of it, so an edit that type-checks in isolation can still break dependents.
  • 跳转定义——解析被引用的视图、表、源或索引的定义位置,包括跨模式的引用。
  • 悬停查看——无需打开对象定义,即可查看对象的列及其类型。
  • 文档符号——列出单个
    .sql
    文件中定义的所有对象。
  • 工作区符号——当不知道对象所在文件时,通过名称定位对象。
在修改对象之前,请使用这些功能查找依赖该对象的内容。在Materialize中,视图的定义会约束其下游的所有内容,因此即使某个编辑在孤立环境中通过类型检查,仍可能破坏依赖它的对象。

Diagnostics

诊断功能

Parse errors surface automatically after each edit. Treat them as authoritative for syntax; they come from the same parser
mz-deploy
uses to build the project.
每次编辑后会自动显示解析错误。这些错误是语法的权威参考,因为它们来自
mz-deploy
用于构建项目的同一解析器。

Requirements

要求

mz-deploy
must be on
PATH
(
which mz-deploy
). If every navigation request comes back empty while the server looks healthy, the plugin's mz-deploy project directory setting is pointing somewhere other than the directory holding
project.toml
. The server takes that directory as its project root, and a project nested in a subdirectory needs the setting to name that subdirectory. Report this rather than falling back to grep — a stale setting is worth fixing once.
mz-deploy
必须在
PATH
环境变量中(可通过
which mz-deploy
验证)。如果服务器状态正常但所有导航请求均返回空结果,说明插件的mz-deploy项目目录设置指向的并非包含
project.toml
的目录。服务器会将该目录作为项目根目录,若项目嵌套在子目录中,需将设置指定为该子目录。请反馈此类问题,而非退回到grep——修复一次过期设置即可一劳永逸。